在我的应用程序中,我有多个视图,一些视图需要同时支持纵向和横向,而其他视图只需要支持纵向.因此,在项目总结中,我 Select 了所有方向.
以下代码用于在iOS 6之前的给定视图控制器上禁用横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
由于iOS6中不推荐使用shouldAutorotateToInterfaceOrientation,我将上面的内容替换为:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
当视图出现时,这个方法被正确调用(我可以设置一个断点来确保这一点),但是界面仍然会旋转到横向模式,而不管我只返回纵向模式的遮罩.我做错了什么?
目前似乎不可能构建一个每个视图都有不同方向要求的应用程序.它似乎只遵循项目摘要中规定的方向.