0

I need block a screen. im using the next fuctions:

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

but the problem is that i have a show alert function,

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
}

and when i call it i see the error:

Terminating app due to uncaught exception

'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES'

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
BarneyL. BarStin
  • 333
  • 1
  • 7
  • 20

2 Answers2

0

Refer the following links and based on this you can change in your code. Please search before asking question.

  1. iOS 8.3 supported orientations crashs

  2. 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

  3. Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

Community
  • 1
  • 1
Venk
  • 5,949
  • 9
  • 41
  • 52
0

Your supportedInterfaceOrientations method implementation looks wrong. Try changing it to something like the following:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.Portrait
}
Adam
  • 26,549
  • 8
  • 62
  • 79