Prevent AlertView from auto rotating

喜欢而已 提交于 2019-12-01 21:44:44

Try doing this in viewDidAppear:. I've seen weird behavior like this before because view layouts are not entirely defined yet. In viewDidAppear:, everything is set and laid out, so there shouldn't be any problems at that point.

Have you try with implementing shouldAutorotate ? You can do in your case :

- (BOOL)shouldAutorotate
{
    if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) return NO;
    else return YES;
}

I was experiencing this, but the alert was being shown from the AppDelegate. After reading Scott Berrevoet's answer about view layouts not being entirely defined yet I added a very slight delay before showing the alert dialog to give everything some time to set up and that fixed the problem.

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
    [self.updateAlert show];
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!