美文网首页
APP在iPad上调用系统相册,旋转iPad横屏导致闪退。

APP在iPad上调用系统相册,旋转iPad横屏导致闪退。

作者: 不踏沧桑路 | 来源:发表于2020-11-30 00:38 被阅读0次
APP在iPhone上调用相册正常,因为没有特意适配iPad,其中一个功能需要调用系统相册,在iPad上打开相册时遇到了崩溃的情况。崩溃原因如下:
reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
异常的原因是控制器中返回的屏幕方向与AppDelegate中支持的屏幕方向不一致,搜索后发现这个问题解决方法比较多,不同的场景和业务应该考虑使用不同的解决思路。我在参考了这篇文章后解决了问题。

先放上参考文章链接
解决思路为:在AppDelegate中添加返回屏幕方向的方法,

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

然后为UIImagePickerController添加分类方法:

- (BOOL)shouldAutorotate {
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskLandscape;
}

判断是iPad时不支持屏幕旋转。

相关文章

网友评论

      本文标题:APP在iPad上调用系统相册,旋转iPad横屏导致闪退。

      本文链接:https://www.haomeiwen.com/subject/nowpiktx.html