I want a user to spin a picker and as a specific row appears, it should load an appropriate array and display it in a UITableView. I would prefer it if the user did not have to spin the picker and then press a separate "select" button.
I have the usual picker and table methods, but the table won't update as the picker is spun. The table does update on the initial NIB load, but nothing thereafter.
This is the picker method. The arrays are loaded and reloadData is called , but then nothing...?
Help appreciated.
(void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row 开发者_Python百科inComponent:(NSInteger)component {
NSLog(@"Selected: %@. Index: %i", [pickerSelections objectAtIndex:row], row);
pickerChoice = [pickerSelections objectAtIndex:row];
if (pickerChoice==@"String1"){
NSLog(@"load Array1");
Names1 = [[NSArray alloc]initWithObjects:@"Bob Jones",@"Joe Brown",@"Nigel Smith",nil];
[contactTable reloadData];
}else if (pickerChoice==@"String2"){
NSLog(@"load Array2");
Names2 = [[NSArray alloc]initWithObjects:@"Bob Jennings",@"Joe Brown",@"Nigel Smith",nil];
[contactTable reloadData];
}
}
Groan - my bad. I triple checked everything and then noticed I had forgotten to add "IBOutlet" in the @property for the table and picker. What was I thinking. Once added, I was able to connect in IB (of course) and everything fire up just fine.
精彩评论