Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotation problems when a UIAlertView is showing in iOS 7

in iOS7, rarely but occassionally, when I rotate my app while a UIAlertView is showing, only the alertView and the status bar rotate, and not my app. Has anybody else experienced this and/or have found a workaround?

like image 807
Mohamed Hafez Avatar asked Nov 08 '13 02:11

Mohamed Hafez


2 Answers

I've resolved this issue by adding the next method to app delegate:

- (void)application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation duration:(NSTimeInterval)duration  {
NSArray *windows = [application windows];
for (UIWindow *nextWindow in windows) {
    [[nextWindow.rootViewController class] attemptRotationToDeviceOrientation];
     }
}
like image 119
Catherine Avatar answered Nov 05 '22 23:11

Catherine


I had the opposite problem. My app would rotate but the alert view would not rotate. I found out that this was because I was showing the alert view immediately after a UIActionSheet was dismissed (so while it's dismissal animation was taking place). This seemed to be triggering a bug that will make the alert view not rotate with the app (and some other minor visual problems later). I solved this by presenting the alert view a half second after the action sheet begins to dismiss, like this:

[alertView performSelector:@selector(show) withObject:nil afterDelay:0.5];
like image 43
spybart Avatar answered Nov 06 '22 00:11

spybart