我的应用程序是Landscape基于。当应用程序在我的设备上运行时,应用程序会立即崩溃。
我选择了这两个字段
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
我收到此错误:
由于未捕获的异常 UIApplicationInvalidInterfaceOrientation 终止应用程序,原因:支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 YES
我的应用程序是Landscape基于。当应用程序在我的设备上运行时,应用程序会立即崩溃。
我选择了这两个字段
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
我收到此错误:
由于未捕获的异常 UIApplicationInvalidInterfaceOrientation 终止应用程序,原因:支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 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.
}
您应该使用 UIInterfaceOrientationMaskLandscape 而不是 UIInterfaceOrientationLandscapeLeft 和 UIInterfaceOrientationLandscapeRight。在 iOS SDK 6.0+ 中,新的 enum(UIInterfaceOrientationMask) 用于返回支持的方向。
shouldAutorotateToInterfaceOrientation 只返回那些你想支持的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
请检查另外一件事,File's Owner and View如果视图不会与文件的所有者附加它之间的连接,它将崩溃。