应用程序由于InterfaceOrientation而崩溃

编程入门 行业动态 更新时间:2024-10-08 10:55:17
本文介绍了应用程序由于InterfaceOrientation而崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的应用程序基于 Landscape .当应用程序在我的设备上运行时,该应用程序立即崩溃.

My application is Landscape based. The app crashes immediately when the app runs on my device.

我选择了这两个字段

UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight

我收到此错误:

由于未捕获的异常而终止应用程序UIApplicationInvalidInterfaceOrientation,原因:受支持方向与应用程序没有共同的方向,并且shouldAutorotate返回YES

Terminating app due to uncaught exception UIApplicationInvalidInterfaceOrientation, reason: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES

推荐答案

向控制器添加 shouldAutorotate 和 supportedInterfaceOrientations 方法.

-(BOOL)shouldAutorotate { return YES; //this will auto-rotate the orientation. } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; // will force the app to load in landscape, you can change it as per your need. }

更多推荐

应用程序由于InterfaceOrientation而崩溃

本文发布于:2023-11-03 05:03:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554302.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   InterfaceOrientation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!