我在程序中包含了一个UIPicker。它包含2个内容,例如A和B.我需要的是假设用户从选择器中选择了A,它应该移动另一个故事板。我能够转移到另一个视图,但它没有显示任何内容。我将粘贴下面的代码: -
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
DemoViewController *demo =[[DemoViewController alloc] init];
AnotherViewController *another =[[AnotherViewController alloc] init];
NSString *content=[aray objectAtIndex:row];
if ([content isEqualToString:@"A"])
{
[self presentModalViewController:demo animated:YES];
}
else {
[self presentModalViewController:another animated:YES];
}
}
任何人都可以告诉我为什么我会得到一个空白的故事板?
答案 0 :(得分:1)
显示您使用的故事板中的另一个场景执行'segue',例如
[self performSegueWithIdentifier:@“demo”sender:self];
确保保留所选值的实例变量, 然后在'prepare for segue'中将此值传递给目标视图控制器,例如
[segue.destinationViewController setChosenValue:self.pickedValue];