ios - shouldAutorotateToInterfaceOrientation 返回 YES

标签 ios cocoa-touch ios5

我经常看到这样的代码:

- (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/

相关文章:

ios - 如何清除 FaSTLane gym 输出目录?

ios - DateFormatter 使用不正确的时区格式化字符串

iphone - 为什么 UITableViewController 不应该管理 Cocoa Touch 中窗口的一部分?

ios - UILocalNotification特殊字符警报正文

objective-c - 在 iOS 中保持套接字连接

ios - 限制 FlipsideViewController 方向

ios - 粒子过滤器 iOS 实现失败

ios - iOS CollectionView 中的单元格重新排序

ios - 将 utc 日期转换为 12 小时本地日期?

objective-c - 从 NSArray 获取随机单词有困难