相关疑难解决方法(0)

iOS6:supportedInterfaceOrientations不工作(调用但接口仍然旋转)

在我的应用程序中,我有多个视图,一些视图需要支持纵向和横向,而其他视图只需要支持纵向.因此,在项目摘要中,我已经选择了所有方向.

以下代码用于在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)

当视图出现时我会正确调用此方法(我可以设置断点以确保这一点),但是界面仍然会旋转到横向模式,而不管我是否仅为纵向模式返回蒙版.我究竟做错了什么?

似乎目前无法构建一个每个视图具有不同方向要求的应用程序.它似乎只遵循项目摘要中指定的方向.

iphone objective-c ios ios6

50
推荐指数
6
解决办法
5万
查看次数

如何使应用程序在iOS 6中完全正常工作以进行自动旋转?

在iOS6中,shouldAutorotateToInterfaceOrientation已弃用.我尝试使用 supportedInterfaceOrientationsshouldAutorotate 使应用程序正常工作自动旋转但失败了.

这个ViewController我不想旋转,但它不起作用.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?在此先感谢您的帮助!

uiviewcontroller autorotate ios ios6

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

标签 统计

ios ×2

ios6 ×2

autorotate ×1

iphone ×1

objective-c ×1

uiviewcontroller ×1