在我的应用程序中,我有多个视图,一些视图需要同时支持纵向和横向,而其他视图只需要支持纵向。因此,在项目总结中,我已经全部选择了所有方向。
以下代码在iOS 6之前的版本中禁用了给定视图控制器上的横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
由于shouldAutorotateToInterfaceOrientation在iOS6中已被弃用,因此我将上面的代码替换为:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
当视图出现时,这个方法被正确调用(我可以设置一个断点来确保这一点),但是界面仍然旋转到横向模式,而不管我只为纵向模式返回掩码的事实。我做错了什么?
似乎目前还不可能构建一个对每个视图有不同方向要求的应用程序。它似乎只遵循项目摘要中指定的方向。
https://stackoverflow.com/questions/12447552
复制相似问题