我的应用程序(iPad; iOS 6)是一个仅限风景的应用程序,但是当我尝试使用UIPopoverController来显示照片库时,它会抛出此错误:
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES.我尝试更改了很多代码,但我没有运气.
由于ShouldAutorotateToInterfaceOrientation在iOS 6中已弃用并且我使用它来强制特定视图仅限于纵向,在iOS 6中执行此操作的正确方法是什么?这仅适用于我的应用的一个区域,所有其他视图都可以旋转.
在我的应用程序中,我有多个视图,一些视图需要支持纵向和横向,而其他视图只需要支持纵向.因此,在项目摘要中,我已经选择了所有方向.
以下代码用于在iOS 6之前禁用给定视图控制器上的横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)
由于在iOS6中不推荐使用shouldAutorotateToInterfaceOrientation,我将以上内容替换为:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
Run Code Online (Sandbox Code Playgroud)
当视图出现时我会正确调用此方法(我可以设置断点以确保这一点),但是界面仍然会旋转到横向模式,而不管我是否仅为纵向模式返回蒙版.我究竟做错了什么?
似乎目前无法构建一个每个视图具有不同方向要求的应用程序.它似乎只遵循项目摘要中指定的方向.