相关疑难解决方法(0)

preferredInterfaceOrientationForPresentation必须返回支持的接口方向

此错误没有意义,因为UIInterfaceOrientationLandscapeRight支持的方向返回首选方向

//iOS6

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}
Run Code Online (Sandbox Code Playgroud)

错误:

由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因是:'preferredInterfaceOrientationForPresentation必须返回支持的接口方向!'

cocoa ios ios6

30
推荐指数
3
解决办法
4万
查看次数

iOS 6.0中的界面方向

如何使用以下方法在iOS 6.0中支持界面方向:

shouldAutorotate

supportedInterfaceOrientations

preferredInterfaceOrientationForPresentation
Run Code Online (Sandbox Code Playgroud)

由于"shouldAutorotateToInterfaceOrientation"在iOS 6.0中已弃用.

请提供代码段以支持您的答案.

谢谢.

iphone xcode ipad ios ios6

25
推荐指数
4
解决办法
4万
查看次数

了解iOS 6界面方向更改

补充: 我看到我的问题经常在没有赞成的情况下被查看,所以我决定你们没有得到你搜索的内容.重定向到有关如何处理iOS6中的方向更改的答案非常好的问题

方向变化的具体要求: 限制轮换

欢迎Upvotes :)


我已经从Master Detail模板创建了一个新项目,并尝试以横向方向启动它.如你所知

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

方法已弃用,我们必须使用

- (NSUInteger)supportedInterfaceOrientations

和/或

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

这是我的代码:

- (NSUInteger)supportedInterfaceOrientations {
    NSLog(@"supported called");
    return UIInterfaceOrientationMaskAll;//Which is actually a default value
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    NSLog(@" preferred called");//This method is never called. WHY?
    return UIInterfaceOrientationLandscapeRight;
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样,我试图在首选方法中返回横向,但它永远不会被调用.ps文档说明:

讨论系统在全屏显示视图控制器时调用此方法.当视图控制器支持两个或更多方向时,您可以实现此方法,但内容在其中一个方向中最佳.

如果视图控制器实现此方法,则在显示时,其视图将以首选方向显示(尽管稍后可以将其旋转到另一个受支持的旋转).如果未实现此方法,系统将使用状态栏的当前方向显示视图控制器.

所以,问题是:为什么永远不会调用prefferredOrientation方法?我们应该如何在不同的控制器中处理不同的方向?谢谢!PS不会将问题标记为重复.我调查了所有类似的问题,他们没有我的答案.

iphone objective-c uiinterfaceorientation ios6

23
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios6 ×3

ios ×2

iphone ×2

cocoa ×1

ipad ×1

objective-c ×1

uiinterfaceorientation ×1

xcode ×1