rotation problems when a UIAlertView is showing in iOS 7

淺唱寂寞╮ 提交于 2019-11-29 01:38:46

问题


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?


回答1:


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



回答2:


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];



回答3:


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.



来源:https://stackoverflow.com/questions/19850434/rotation-problems-when-a-uialertview-is-showing-in-ios-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!