博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
横屏下调用相机崩溃问题
阅读量:6905 次
发布时间:2019-06-27

本文共 781 字,大约阅读时间需要 2 分钟。

注:这个问题在最新的系统iOS11上是没有问题的,但是我们要兼容之前的版本,最起码要兼容iOS10的

在项目处于横屏状态下,调用相机或者相册,出现崩溃, 报错内容为:'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES.

原因为当前的项目只支持横屏,不支持竖屏,相册只能在竖屏下显示,这就导致的项目的崩溃

解决办法就是在调用相机的时候,修改项目支持的方向,包含竖屏就可以,在AppDelegate中有一个项目支持的方向的方法,

- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{if (self.interfaceOri == 1) {    return UIInterfaceOrientationMaskAllButUpsideDown;}else if (self.interfaceOri == 2){    return UIInterfaceOrientationMaskLandscapeRight;}else {    return UIInterfaceOrientationMaskPortrait;}}复制代码

只需要修改其中的self.interfaceOri参数(这个参数自己定义一个全局的数据就好,最好是某个单例里面的数据)即可,系统会自动调用这个方法

转载地址:http://wzmdl.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
mysqldump工具
查看>>
用 PHP 读取文件的正确方法
查看>>
LoadRunner压力测试时监控服务器Linux的资源情况
查看>>
azure存储并发写 压力测试
查看>>
管理用户和用户权限
查看>>
VCTransitionsLibrary –自定义iOS交互式转场动画的库
查看>>
final、static(Java)和const、static(C#)
查看>>
C语言利用中心极限定理产生高斯白噪声
查看>>
电脑定时关机
查看>>
Disconf-Web管理端安装
查看>>
PHP-防止SQL注入
查看>>
Javascript监听 ESC按下事件
查看>>
Comet技术详解:基于HTTP长连接的Web端实时通信技术
查看>>
MongoDB:Ruby中嵌入Javascript实战
查看>>
亚马逊云服务与IT的未来:微博速递
查看>>
博客收藏
查看>>
关于ant-design表单问题
查看>>
十三、MySQL数据备份与恢复
查看>>
编程的修炼(中英双语)
查看>>