【问题标题】:Present Modal View in Detail View in UISplitViewController在 UISplitViewController 的详细视图中显示模态视图
【发布时间】:2016-10-25 19:41:15
【问题描述】:

我想在 iPad 中以横向模式制作类似联系人应用程序的行为。

当我点击上方右添加按钮时,我希望在详细视图中显示模态框。

但是现在如果我点击右上角的添加按钮Modal 会在所有屏幕中显示

我应该使用什么方法?显示详细视图控制器?或presentViewController?我不知道如何仅在详细视图中显示模态。

【问题讨论】:

  • 是的,这里也是,你找到答案了吗?

标签: ios xcode ipad uinavigationcontroller uisplitviewcontroller


【解决方案1】:

首先你需要设置细节视图控制器的属性definesPresentationContext = true。所以现在它定义了presentation context。默认情况下,视图控制器在呈现时不会关注当前上下文,因此您必须执行viewController.modalPresentationStyle = .CurrentContext

这就是完整方法的样子

func adaptivePresentViewController(viewController: UIViewController) {
  let detailVC = splitViewController!.viewControllers[1]
  detailVC.definesPresentationContext = true
  viewController.modalPresentationStyle = .CurrentContext
  detailVC.presentViewController(viewController, animated: true, completion: nil)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多