I need to load a view based on [PickerView didSelectRow:(NSInteger)row inComponent(NSInteger)component
]
I have the highlight and selection logic figured out, what I need now is just a simple way of determining if the select button has been pressed to load the view.
Is this possible?
For example,
if ( /* select button is pressed */ )
{
//push selected view onto stack.
}
Update
Here, I'll post code so you can see what I have going. I have most everything setup via nib files.
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
/*
//do simple error checking to ensure nothing badly crazy happens
if(row > [mPickerMenuItems count])
{
NSLog(@"Row index is out of bounds of mPickerMenuItems length in [Overview pickerView:(UIPickerView*) didSelectRow:(NSInteger) inComponent:(NSInteger)]...bailing out");
return;
}
else if(row < 0)
{
NSLog(@"Row index is negative in [Overview pickerView:(UIPickerView*) didSelectRow:(NSInteger) inComponent:(NSInteger)]...bailing out.");
return;
}
*/
NSString* selected = [_pickerMenuItems objectAtIndex:row];
//NSLog(@"(in [Overview pickerView: didSelectRow]) resultLabel.text => %@", mResultLabel.description);
if([selected isEqualToString:@"My Profile"])
{
if ( /* select button is pressed */ )
{
//push view onto stack.
}
NSLog(@"My Profile has been selected");
}
else if([selected isEqualToString:@"Services"])
{
NSLog(@"Services has been selected");
}
else if([selected isEqualToString:@"Tools"])
{
NSLog(@"Tools has been selected");
}
else if([selected isEqualToString:@"Media"])
{
NSLog(@"Media has been selected");
}
else
{
NSLog(@"Nothing has been selected in [Overview pickerView: didSelectRow]");
}
}
Update 2
Sorry for the confusion. I guess what I should say is that I want to fire the view switch as soon as the UIBarButtonItem
is selected, based on the on the item highlighted in the UIPickerView
. I'm pretty sure if I went with the natural choice of just using the method I have and if-else
ing it all, it would switch and load, but NOT when the select button is pressed.
How is this done?