以下代码在iOS 6之前的给定视图控制器上禁用横向模式:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
由于 shouldAutorotateToInterfaceOrientation 在 iOS6 中已经被废弃,因此我已经用以下方法替换:
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMask.Portrait;
}
我可以设置断点以确保此方法在视图出现时被正确调用,但界面仍会旋转为横屏模式,而不考虑我仅返回纵向模式的掩码。 我做错了什么?
目前似乎无法构建具有每个视图不同方向要求的应用程序。它似乎只遵循项目摘要中指定的方向。