更正UINavigationController方向

时间:2016-10-14 13:52:26

标签: ios swift uinavigationcontroller

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

以下是我如何呈现它们:

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)
}

1 个答案:

答案 0 :(得分:0)

我已经暂时解决了设置

后纠正框架的问题
CREATE TABLE device_strings (
  id text,
  year_month_day text,
  start timestamp,
  end timestamp,
  value text,
  PRIMARY KEY ((id, year_month_day), start, end)
);

喜欢这样

self.centerNavigationController = navigationViewController

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