Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8.3 supported orientations crashs

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?

like image 772
Anna565 Avatar asked Apr 14 '15 13:04

Anna565


3 Answers

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;
}
like image 173
Lucas van Dongen Avatar answered Oct 24 '22 02:10

Lucas van Dongen


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

like image 34
mkeremkeskin Avatar answered Oct 24 '22 01:10

mkeremkeskin


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

like image 1
Josh Hudnall Avatar answered Oct 24 '22 01:10

Josh Hudnall