7

I have a big problem with my app and iOS 8.3. I have many crashes with always the same error:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [... shouldAutorotate] is returning YES

When "..." are many classes. A particular problem is the class UIAlertView, I have the same problem of UIAlertView crashs in iOS 8.3 but I can't resolve subclassing UIAlertView (Apple says that the UIAlertView class is intended to be used as-is and does not support subclassing) or using UIAlertController. Can you help me?

Community
  • 1
  • 1
Anna565
  • 735
  • 2
  • 10
  • 21
  • "Supported orientations has no common orientation with the application" appeared for me when f.e application doesn't support landscape but UIViewController returns YES for landscape – Injectios Apr 14 '15 at 14:33
  • We cannot help you without code to see how you are subclassing UIAlertView. – Black Frog Apr 14 '15 at 14:33
  • Apple says that the UIAlertView class is intended to be used as-is and does not support subclassing, I can't subclass UIAlertView so I can't show you nothing – Anna565 Apr 14 '15 at 14:38
  • change to UIAlertController, UIAlertView is deprecated – jcesarmobile Apr 14 '15 at 14:39
  • I change but the error is always the same: Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES' – Anna565 Apr 14 '15 at 14:46

4 Answers4

6

A lot of other apps didn't crash with this bug, so I was wondering if there was something else in our app that accounted to this crash. I made sure iOS 8 would get the UIAlertController so it wouldn't crash but that doesn't help with third-party frameworks.

Another engineer in our team eventually fixed it by doing this:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
    // This used to be:
    //return UIInterfaceOrientationPortrait;
}
Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
2

I don't know what changed from iOS 8.2 to 8.3 and why they changed it, because it was working fine. It's annoying.

Anyway I solved this problem with the gist on link.

https://gist.github.com/mkeremkeskin/0ed9fc4a2c0e4942e451

mkeremkeskin
  • 644
  • 10
  • 27
1

After trying the solutions here, none of them worked for me. I'm supporting iOS 6-8 in an app, and, more than that, use some libraries that use UIAlertView internally, so simply conditionally compiling to use UIAlertController when available was not an option.

I came up with a solution that solved the problem for me. Your mileage may vary. I include the header file in the Header Prefix file so that it's sure to be included anywhere a UIAlertView is shown.

I'm posting this here for anyone who's stumbling on this problem and the solutions found around the net don't work. Hopefully it's helpful.

https://gist.github.com/joshhudnall/cdc89b61d0a545c85d1d

Josh Hudnall
  • 1,021
  • 8
  • 16
0

I solved this problem with this:

if objc_getClass("UIAlertController") != nil {

     println("UIAlertController can be instantiated")

     //make and use a UIAlertController iOS8

}
else {

     println("UIAlertController can NOT be instantiated")

     //make and use a UIAlertView iOS7
}

Then you can keep your app run in iOS 7 and iOS 8

bandojulio
  • 129
  • 2
  • 5