gpt4 book ai didi

ios - 纠正 UINavigationController 方向

转载 作者:行者123 更新时间:2023-11-30 12:59:09 28 4
gpt4 key购买 nike

我有一个 UINavigationControllers 数组,我想将其呈现在自定义侧面菜单 Controller 中。这一切都有效,但是当我将设备方向更改为横向,然后从之前以纵向呈现的数组中呈现 UINavigationController 时,它不会旋转,它只会显示在屏幕外...有没有办法在显示之前纠正 UINavigationControllers 方向?

以下是我介绍它们的方式:

func presentNavigationViewController(_ navigationViewController: UINavigationController) {

//// removing old centerNavigationController
self.centerNavigationController?.view.removeFromSuperview()
self.centerNavigationController?.view.removeGestureRecognizer(panGestureRecognizer)
self.centerNavigationController?.removeFromParentViewController()

self.centerNavigationController = navigationViewController

//// corecting view position based on status of side menu
switch self.currentState {
case .Expanded:
self.centerNavigationController.view.frame.origin.x = centerNavigationController.view.frame.width - ContainerViewController.centerPanelExpandedOffset
case .Collapsed:
self.centerNavigationController.view.frame.origin.x = 0
}

//// and presenting
self.view.addSubview(centerNavigationController.view)
self.addChildViewController(centerNavigationController)
self.centerNavigationController.didMove(toParentViewController: self)
self.centerNavigationController.view.addGestureRecognizer(panGestureRecognizer)
}

最佳答案

我暂时解决了设置后立即校正框架的问题

self.centerNavigationController = navigationViewController

像这样

self.centerNavigationController.view.frame = self.view.frame

但我不认为它是理想的解决方案......

关于ios - 纠正 UINavigationController 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40044902/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com