【问题标题】:iOS: Presenting a UIViewController modally (form sheet/page sheet) over splitViewControlleriOS:在 splitViewController 上以模态方式(表单/页面表)呈现 UIViewController
【发布时间】:2014-09-24 08:19:30
【问题描述】:

我有一个 UISplitViewController(是 rootViewController) 和一个 UIViewController,vc1。

我正在尝试通过 MasterViewController 部分的拆分视图控制器呈现 vc1:

vc1.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentViewController:vc1 animated:YES completion:nil];

这引发了一个异常:

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'Application tried to present modally an active 
controller <MasterViewController: 0x8c5dd30>.'

...然后崩溃。

试过这个:

[self.splitViewController presentViewController:vc1 animated:YES completion:nil];

这引发了一个异常:

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason:'Application tried to present modally an active 
controller <UISplitViewController:0x8c7e3a0>.'

但是,如果我尝试使用界面构建器(segues),它可以工作。

我如何以编程方式在拆分视图控制器上以模态方式(作为页面表或表单表)呈现视图控制器?

【问题讨论】:

  • vc1 在 UINavigationController 中吗?
  • @cortez 不,它是分开的。

标签: ios ipad uiviewcontroller uisplitviewcontroller


【解决方案1】:

您可以告诉 DetailView 控制器显示它。我猜是这样的。

DetailVC *detailVC = [self.splitViewController.viewControllers objectAtIndex:1];
[detailVC presentViewController:vc1 animated:YES completion:nil];

我想问题是你的主人正在呈现一个细节视图,这就是为什么它不能呈现任何其他东西,所以你要求细节视图为你做。

【讨论】:

    猜你喜欢
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    • 2021-03-15
    • 1970-01-01
    相关资源
    最近更新 更多