为什么我有这个showAlert错误?

时间:2015-08-10 12:45:54

标签: ios xcode swift

我需要屏蔽一个屏幕。即时通讯使用下一个功能:

override func shouldAutorotate() -> Bool {
    return false
}
override func supportedInterfaceOrientations() -> Int {
    return UIInterfaceOrientation.Portrait.rawValue
}

但问题是我有一个节目提醒功能,

func showAlert(message: String) {
    self.viewUtils.hideActivityIndicator(self.view)
    let alertView = UIAlertController(title: "Oops", message: message, preferredStyle: UIAlertControllerStyle.Alert)
    alertView.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))


    self.presentViewController(alertView, animated: true, completion: nil)
    //activity.hidden = true
}

当我打电话给我时,我看到了错误:

由于未捕获的异常而终止应用

  

'UIApplicationInvalidInterfaceOrientation',原因:'支持的方向与应用程序没有共同的方向,[UIAlertController shouldAutorotate]返回YES'

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

您的supportedInterfaceOrientations方法实现看起来不对。尝试将其更改为以下内容:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.Portrait
}
相关问题