我经常看到这样的代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
如果在项目配置中设置了支持的方向,那么一直返回YES岂不是毫无意义?或者在某些情况下这会产生影响?
最佳答案
shouldAutorotateToInterfaceOrientation:
(顺便说一句,自 iOS 6 起已弃用)与信息 plist 中的 UISupportedInterfaceOrientations
完全不同!如果您不实现此方法,则无论您在 UISupportedInterfaceOrientations
中指定什么,相应的 View Controller 都不会自动旋转到该界面方向。
来自documentation of UISupportedInterfaceOrientations
:
The system uses this information (along with the current device orientation) to choose the initial orientation in which to launch your app.
关于ios - shouldAutorotateToInterfaceOrientation 返回 YES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13141849/