Working on an App for Ipad which has one main view controller and 3 popover views, each popover view has a UIPicker, I want to display in 3 different labels located in the main view controller the UIPickers selection, each label is asociated to its own UIPicker. I had been trying with delegate objects to pass the data from the pickers to the labels but something is wrong. Any clue PLEASE! Thanks.
The easiest way is to use tags.
typedef enum {
FirstPicker = 1,
SecondPicker,
ThirdPicker
} PickerTags;
When you create the picker, indicate which one it is by setting the tag either in storyboard or like this
picker.tag = FirstPicker;
In your picker callbacks it is now easy to identify the picker:
- (void)pickerView:(UIPickerView *)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component {
if (picker.tag == FirstPicker) { /* handle first picker */ }
// etc.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.