Application is crashed due to InterfaceOrientation

放肆的年华 提交于 2019-12-11 04:49:59

问题


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

I have selected these two fields

UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight

I am getting this error:

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


回答1:


Add shouldAutorotate and supportedInterfaceOrientations methods to your controller.

 -(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.

}



回答2:


shouldAutorotateToInterfaceOrientation return only those with you want to support

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

please check one more thing, the connection between the File's Owner and View, if the view will not attach with the file's Owner It will crash.




回答3:


You should use UIInterfaceOrientationMaskLandscape instead of UIInterfaceOrientationLandscapeLeft & UIInterfaceOrientationLandscapeRight. In iOS SDK 6.0+, new enum(UIInterfaceOrientationMask) is used for returning supported orientations.



来源:https://stackoverflow.com/questions/14100233/application-is-crashed-due-to-interfaceorientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!