【发布时间】:2012-09-08 23:28:43
【问题描述】:
在我的应用中,我有多个视图,一些视图需要同时支持纵向和横向,而其他视图只需要支持纵向。因此,在项目摘要中,我选择了所有方向。
以下代码用于在 iOS 6 之前禁用给定视图控制器上的横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
由于 shouldAutorotateToInterfaceOrientation 在 iOS6 中已被弃用,我已将上述内容替换为:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
当视图出现时,这个方法被正确调用(我可以设置一个断点来确保这一点),但是界面仍然旋转到横向模式,不管我只为纵向模式返回掩码。我做错了什么?
目前似乎不可能构建每个视图具有不同方向要求的应用。它似乎只遵循项目摘要中指定的方向。
【问题讨论】:
-
请参考此 [链接][1] 可能会有所帮助。 [1]:stackoverflow.com/questions/12526054/…
-
在这里,我在标签栏控制器中发布了我的解决方案/经验,带有旋转:stackoverflow.com/a/12774037/751641
-
我遇到了同样的问题。以下答案很有帮助:stackoverflow.com/questions/12996293/…
标签: iphone objective-c ios ios6