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

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时不支持屏幕旋转。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容