在选择器视图中将图像和文本一起添加 [英] Adding image together with text in a picker view
问题描述
我们可以在选择器视图中将图像和文本一起添加吗?
任何人都可以帮助!
Can we add image together with text in a picker view? Anyone please help!
推荐答案
在选择器视图的委托中有
In picker view's delegate there is
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
方法,您可以在其中创建自定义视图(可以是带有UILabel和UIImageView的UIView)并返回它-所以UIPickerView将使用它来表示行。有关更多信息,请参见参考。
method, where you can create your custom view (may be UIView with UILabel and UIImageView in your case) and return it - so UIPickerView will use it for row representation. See reference for more information.
如果您使用此方法返回 UIView *
,则可能还需要设置其 userInteractionEnabled
属性设置为否,否则,如果您点击行,选择器将不会选择行。
If you return UIView*
in this method you may also need to set its userInteractionEnabled
property to NO, otherwise picker will not select rows if you tap them.
这篇关于在选择器视图中将图像和文本一起添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!