我正在制作一个应用程序,仅在播放视频时支持横向方向。否则,所有场景仅支持纵向方向。我已在项目设置中检查了纵向、左右横向。我已在想要限制为仅使用纵向的ViewController中编写了以下代码。
override func viewWillAppear(animated: Bool) {
let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> Int {
return UIInterfaceOrientation.Portrait.rawValue
}
然而,当我按下(Command+左或右箭头)时,模拟器会旋转。因为我没有设备,所以必须在模拟器中测试。
请帮忙!谢谢!