我有一个视图控制器,我想保持横向模式 . 我在课程中添加了以下代码:
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Landscape
}
func navigationControllerSupportedInterfaceOrientations(navigationController: UINavigationController) -> UIInterfaceOrientationMask
{
return UIInterfaceOrientationMask.Landscape
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation
{
return UIInterfaceOrientation.LandscapeLeft
}
当我打开UIImagePickerController来选择照片时 . 如果我在选择器中单击取消,应用程序将以纵向模式返回到我的视图控制器 . 当我回到我的控制器时,我也试过设置方向,它只适用于第一次:
UIDevice.currentDevice().setValue(orientationBeforeShowingImagePicker.rawValue, forKey: "orientation")
1 回答