如何将摄像头视图方向锁定为iOS横向?
答
在您的视图控制器将这个:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.current.orientation.isLandscape {
print("will turn to landscape")
} else {
print("will turn to portrait")
//print an alert box here
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
}
}
来源:How to detect orientation change?
或者把这个需要在横向视图:
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape
}
但是这一个不能发布一个警报。
@LijithVipin - portait被锁定意味着 –
@ LiJithVipin我不明白你想说什么,你能详细说明一下吗? – paper1111