Changing UIPickerView row height

前提是你 提交于 2019-12-30 03:02:39

问题


I'm working on a program for a class I'm taking and part of the program requires a UIPickerView with images in it. I have the picker up and running, but the height of the rows in the picker are still too small, causing the images (100x100) to overlap. I'm looking for a way to change the UIPickerView so that the images will fit in one row, without overlapping. Thanks


回答1:


In the documentation for the UIPickerView, you have a link to the UIPickerViewDelegate protocol. There is a method that you can implement, pickerView:rowHeightForComponent:.




回答2:


use this method,provide default as a delegete method.

objective-C

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
    return 40;
}

In Swift:

func pickerView(pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat 
{   
    return 40
}

for more visit : real world implementation



来源:https://stackoverflow.com/questions/6397947/changing-uipickerview-row-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!