首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在iOS 6中让app完全正确地进行自动旋转?

如何在iOS 6中让app完全正确地进行自动旋转?
EN

Stack Overflow用户
提问于 2012-09-30 23:03:48
回答 1查看 16.2K关注 0票数 17

在iOS6中,不推荐使用shouldAutorotateToInterfaceOrientation。我尝试使用supportedInterfaceOrientationsshouldAutorotate来使应用程序正确地工作于自动旋转,但失败了。

这个ViewController我不想旋转,但它不工作。

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

有什么想法吗?提前感谢大家的帮助!

EN

回答 1

Stack Overflow用户

发布于 2012-10-03 08:50:14

如果您使用Tab Bar controller而不是导航控制器作为根控制器,您将需要类似地子类UITabBarController。

此外,语法也会有所不同。我成功地使用了以下代码。然后,我在我想要覆盖的视图控制器上成功地使用了上面的示例。在我的例子中,我希望主屏幕不旋转,但我有一个带有电影的常见问题解答屏幕,我自然想要启用横向视图。完美地工作了!只需注意self.modalViewController的语法更改(如果您尝试使用导航控制器的语法,您将得到一个编译器警告)。希望这能有所帮助!

代码语言:javascript
复制
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)shouldAutorotate
{
    return self.modalViewController.shouldAutorotate;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return self.modalViewController.supportedInterfaceOrientations;
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12662240

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档