UIAlertView在iOS 8.3中崩溃

Sim*_*yer 11 objective-c uialertview ios

最近我开始只为使用iOS 8.3的用户接收UIAlertView的崩溃报告

Crashlytics报道:

致命异常:UIApplicationInvalidInterfaceOrientation支持的方向与应用程序没有共同的方向,[_UIAlertShimPresentingViewController shouldAutorotate]返回YES

发生崩溃的行是[alertView show]:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:cancelButtonTitle
                                          otherButtonTitles:nil];
[alertView show];
Run Code Online (Sandbox Code Playgroud)

该代码在应用程序中存在很长时间,现在它开始崩溃.有没有人遇到类似的行为并解决了这个问题?

小智 10

主要是:

UIApplicationInvalidInterfaceOrientation支持的方向与应用程序没有共同的方向

这意味着你已经实现了某个地方

- (NSUInteger)supportedInterfaceOrientations {

    return UIDeviceOrientationPortrait; // or UIInterfaceOrientationPortrait
}
Run Code Online (Sandbox Code Playgroud)

UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait = 0

在该函数中必须返回掩码,如:

UIInterfaceOrientation Mask Portrait为1


Bho*_*ani 9

尝试实现这一点

- (BOOL)shouldAutorotate {
   return NO;
}

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

检查这个:在iPhone中在iOS 7中打开相机时在Lanscape模式下的方向问题