【问题标题】:How to hide UIKit Tabbar in UIViewControllerRepresentable in SwiftUI如何在 SwiftUI 中的 UIViewControllerRepresentable 中隐藏 UIKit Tabbar
【发布时间】:2021-03-21 21:35:56
【问题描述】:

我正在尝试使用UIViewControllerRepresentable 在 SwiftUI 中访问 Storyboard View Controller。我想通过使用planDetailViewController.hidesBottomBarWhenPushed = true 隐藏我们在ItineraryViewController 上应用的 UIKit Tabbar 但该解决方案不起作用。

  let eventGroup : EventGroup?
  func makeUIViewController(context: Context) -> UIViewController {
    guard let planDetailViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "ItineraryViewController") as? ItineraryViewController else {
      fatalError("ViewController not implemented in storyboard")
    }
    planDetailViewController.userActionMode = .viewOnly
    planDetailViewController.itinerary = eventGroup!.event
    planDetailViewController.shouldDisableCalendarVC = true
    planDetailViewController.hidesBottomBarWhenPushed = true
    return planDetailViewController
  }
  func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
  }
}```

【问题讨论】:

    标签: ios swift swiftui storyboard uikit


    【解决方案1】:

    您的 UIViewControllerRepresentable 不会像在 UIKit 中那样被推送到 UINavigationController 中,因此不会尊重 hidesBottomBarWhenPushed。

    最好的方法是使用 Introspect,就像在这个答案中一样:https://stackoverflow.com/a/64182729/3393964

    【讨论】:

    • 先生,我正在使用 IOS 13.6,而 Introspect 在 IOS 14 中。那么我可以在 IOS 13.6 中做什么
    • @OnlineDeveloper Introspect 不是 iOS 14
    猜你喜欢
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 2021-12-15
    • 2020-03-01
    相关资源
    最近更新 更多