问题
Can we add image together with text in a picker view? Anyone please help!
回答1:
In picker view's delegate there is
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row
forComponent:(NSInteger)component reusingView:(UIView *)view
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.
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.
回答2:
The short answer is Yes. You just do the same as you do with UITableView. Creating a custom view to return to the delegate method is all you need to do.
来源:https://stackoverflow.com/questions/2532490/adding-image-together-with-text-in-a-picker-view