我在导航控制器中嵌入了一个视图控制器,如下所示:
导航控制器是一个自定义子类,如下所示
class SNNAvigationViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override var shouldAutorotate: Bool {
return false
}
}
如您所见,我重写了shouldAutorotate来表示false。同样在Camera view controller中,我有:
class CameraViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, CameraButtonDelegate {
...
override var shouldAutorotate: Bool {
return false
}
...
}
但是没有运气,当我打开电话时,视图仍会自动旋转。我在这里想念什么?
答案 0 :(得分:0)
您是否试图在导航控制器中添加此代码?
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
(如果您想要自然肖像)。