rotation problems when a UIAlertView is showing in iOS 7

前端 未结 3 486
旧巷少年郎
旧巷少年郎 2020-12-28 23:47

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 anybod

相关标签:
3条回答
  • 2020-12-29 00:20

    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];
    
    0 讨论(0)
  • 2020-12-29 00:22

    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];
         }
    }
    
    0 讨论(0)
  • 2020-12-29 00:38

    I think the root of the problem in iOS7 that Apple changed the UIAlertView appearance mechanism. From now any show of alertView follows after initiating of two private view controllers

    _UIModalItemAppViewController
    _UIModalItemsPresentingViewController
    

    In other words, now UIAlertView is not a pure view - it is a part of some complicated collection of view controllers with full view controller life cycle.

    0 讨论(0)
提交回复
热议问题