在iOS6中,不推荐使用shouldAutorotateToInterfaceOrientation
。我尝试使用supportedInterfaceOrientations
和shouldAutorotate
来使应用程序正确地工作于自动旋转,但失败了。
这个ViewController我不想旋转,但它不工作。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
有什么想法吗?提前感谢大家的帮助!
发布于 2012-10-03 08:50:14
如果您使用Tab Bar controller而不是导航控制器作为根控制器,您将需要类似地子类UITabBarController。
此外,语法也会有所不同。我成功地使用了以下代码。然后,我在我想要覆盖的视图控制器上成功地使用了上面的示例。在我的例子中,我希望主屏幕不旋转,但我有一个带有电影的常见问题解答屏幕,我自然想要启用横向视图。完美地工作了!只需注意self.modalViewController的语法更改(如果您尝试使用导航控制器的语法,您将得到一个编译器警告)。希望这能有所帮助!
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotate
{
return self.modalViewController.shouldAutorotate;
}
- (NSUInteger)supportedInterfaceOrientations
{
return self.modalViewController.supportedInterfaceOrientations;
}
https://stackoverflow.com/questions/12662240
复制相似问题