我需要加载一个基于[PickerView didSelectRow:(NSInteger)row inComponent(NSInteger)component
]的视图
我已经弄清楚了突出显示和选择逻辑,我现在需要的只是一种简单的方法来确定是否已按下选择按钮来加载视图。
这可能吗?
例如,
if ( /* select button is pressed */ )
{
//push selected view onto stack.
}
更新
在这里,我将发布代码,以便您可以看到我在做什么。我通过 nib 文件进行了大部分设置。
-(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]");
}
}
更新 2
对困惑感到抱歉。我想我应该说的是,我想在UIBarButtonItem
选择 后立即触发视图开关,基于UIPickerView
. 我很确定如果我只是使用我拥有的方法并if-else
全部完成的自然选择,它会切换和加载,但不是在按下选择按钮时。
这是怎么做到的?