【问题标题】:Presenting a new UIViewControler within a UITabBarController在 UITabBarController 中呈现一个新的 UIViewControler
【发布时间】:2016-07-17 20:10:59
【问题描述】:

我有一个带有 NavigationBar 的 UITabBarController。在 NavigationBar 中是一个按钮,它使用 UINavigationController 实例化一个新的 UIViewController:self.presentViewController(nav, animated: true, completion: nil) 并且正如我所料,视图会以全屏显示。

等等,我的问题是:如何在不隐藏/重叠我的 Tabbar 的情况下呈现新的 UIViewController?

【问题讨论】:

  • 你可以试试这样的东西吗:self.tabBarController.selectedViewController.presentViewController(nav, animated: true, completion: nil)
  • 谢谢,我试过了,但对我不起作用

标签: ios swift xcode


【解决方案1】:

您应该确保在您呈现的视图控制器上设置了正确的modalPresentionStyle。也许.CurrentContext.OverCurrentContext。为此,您还应该在selectedViewController 上将definesPresentationContext 设置为true。在您的 UITabBarController 子类中:

nav.modalPresentationStyle = .CurrentContext
self.selectedViewController?.definesPresentationContext = true
self.selectedViewController?.presentViewController(nav, animated: true, completion: nil)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    相关资源
    最近更新 更多