When my PickerView is displayed, I need to fire a selection event so that a text field is updated (as on load up it is blank), below is the method that responds to change events:
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// update things
}
the best I can come up with is (in viewDidLoad of ViewController):
[self pickerView: pickerView didSelectRow: 0 inComponent 0]
this causes an error
"instance method - pickerView: didSelectRow: inComponent:' not found return type defaults to 'id')" but it works?!
(I've named my UIPickerView object 'pickerView' by the way!)
If I understand this correctly, you want to select a row as soon as the UIPickerView appears on the screen. pickerView:didSelectRow:inComponent
is a delegate method (a callback method) that the picker view calls when the user selects a row. It is not to be called by you.
To select a row, use the picker view's selectRow:inComponent:animated:
method.
[self.pickerView selectRow:0 inComponent:0 animated:YES];
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.