【发布时间】:2016-11-26 06:28:07
【问题描述】:
我正在尝试创建一个只支持纵向的应用程序,我尝试在 Target -> General -> Deployment Info -> Portrait
进行设置然后,在 appDelegate.swift
override func shouldAutorotate() -> Bool {
return false
}
AT ViewController.swift
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.Portrait ]
}
但它不起作用..在 ViewController.swift 中,它给了我 错误:
方法不会覆盖其超类中的任何方法
【问题讨论】:
-
选择一个目标并在 Deplayment info 下找到 Device Orientation。
-
您是否取消选中了部署信息中除纵向之外的所有其他方向?
-
是的,我什至清除了 info.plist 中的风景 --> 支持的界面方向
-
在 Swift 3 中,这个函数被一个属性所取代。 override var supportedInterfaceOrientations : UIInterfaceOrientationMask { return UIInterfaceOrientationMask.portrait }(注意 var 而不是 func)
-
@JohnFoong,查看我的帖子here 它会帮助你。
标签: ios swift uiimageview