【问题标题】:How to present unique UITabBarControllers in Swift如何在 Swift 中呈现独特的 UITabBarControllers
【发布时间】:2019-04-20 02:33:05
【问题描述】:

我正在开发一个项目,该项目有两个不同的 UITabBarControllers 来表示应用程序的两种不同状态。我可以在用户登录后设置第一个 UITabBarController 并在按下按钮时显示第二个。但是,在第二个 UITabBarController 中导航时出现了奇怪的行为。

这就是我设置主标签栏的方式。

let mainTabBar = MainTabBarController()
let mainMode = UINavigationController(rootViewController: mainTabBar)
UIApplication.shared.keyWindow?.rootViewController = mainMode

我使用相同的方法导航到第二个标签栏。

let secondaryTabBar = SecondaryTabBarController()
let hiddenMode = UINavigationController(rootViewController: secondaryTabBar)
UIApplication.shared.keyWindow?.rootViewController = hiddenMode

但是,当使用辅助 UITabBarController 时,我在导航到 AVCaptureSession 时会看到来自主 UITabBarController 的视图。更具体地说,我在捕获会话的模态表示下从 mainTabBar 看到了最后一个视图(从中设置了 secondaryTabBar)。问题来了:

    let captureSession = CameraViewController()        
    navigationController?.present(captureSession, animated: true, completion: nil)

【问题讨论】:

    标签: swift uinavigationcontroller uikit uitabbarcontroller


    【解决方案1】:

    我将 CameraViewController 的 modalPresentationStyle 更改为 .overCurrentContext 并解决了问题。从这里得到它:Transparent background for modally presented viewcontroller

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-05
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多