Using a segment control I’m trying to reload 2 UIPickerViews with a new array of data.
My problem is the new array doesn’t show until I scroll up or down on the picker (old data will go away once out of view). I’ve tried using the reloadAllComponents method to no luck. Here is what the code looks like:
//Segment Control
-(IBAction)unitType:(id)sender {
if([sender selectedSegmentIndex]==0){
NSLog(@"unitType change 1");
NSLog(@"before values = %@",units);
[units removeAllObjects];
[units addObject:@"in"];
//etc.
[self.inputUnits reloadAllComponents];
NSLog(@"current values = %@",units);
}else {
NSLog(@"unitType change 2");
NSLog(@"before values = %@",units);
[units removeAllObjects];
[units addObject:@"in^3"];
//etc.
[self.inputUnits reloadAllComponents];
NSLog(@"current values = %@",units);
}
}
IB has 2 UIPickerViews wired up to the file’s owner for both delegate and datasource.
You haven’t hooked up the
UIPickerViewto yourinputUnitsproperty. Thus, your call to-reloadAllComponentsis getting sent tonil, and things are only getting updated when the pickerView wants to show something new (which it does when you scroll).