我需要更新我的通用应用程序以在iPhone上推送一个tableview,但在iPad上以模态方式显示它(因为全屏桌面视图很难看)。我认为这是一个使用自定义UIStoryboardSegue的好机会,但我无法让iPad显示内容。
我第一次尝试呈现时,会调用完成块以及目标中的viewDidLoad。之后会发出警告:
尝试呈现< UINavigationController:0x7fa0be045a80> on< WalkthroughNavigationController:0x7fa0bb8d0f70>其视图不在窗口层次结构中!
我已经确认WalkthroughNavigationController实际上是在视图层次结构中。此代码的重点是将导航控制器添加到层次结构中。
segue中不支持presentViewController吗?
-(void)perform{
UIViewController *source = (UIViewController*)self.sourceViewController;
UIViewController *destination = (UIViewController*)self.destinationViewController;
if (UI_USER_INTERFACE_IDIOM_PHONE()){
// This works with no problem
[source.navigationController pushViewController:destination animated:YES];
} else {
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:destination];
// I've tried various combinations of source, source.view.window, source.navigation controller here. None of them show the modal view.
[source.navigationController presentViewController:nc animated:YES completion:^{
ALog(@"Nothing appeared.");
}];
}
}