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?
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;
}
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
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
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