iphone - shouldAutorotateToInterfaceOrientation 有问题

标签 iphone objective-c ios ipad

我的 UIViewController 中有以下代码,我正在设备和模拟器中测试 iOS 5。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (IS_IPHONE){
        return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
    } else {
        return YES;
    }
}

我设置了一个断点,它确实被调用了,但它仍然旋转到横向。这是为什么?

最佳答案

因为你告诉它这样做。 return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown; 表示您想要自动旋转到除纵向颠倒之外的每个方向,包括横向。对于 iPad,甚至缺少此约束,因此它会自动旋转到任何方向。

(你应该对文档有了新的认识......)

关于iphone - shouldAutorotateToInterfaceOrientation 有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12846704/

相关文章:

ios - 缓存模型(DTO)类供以后使用

ios - 一起动画两个uiview

ios - 以编程方式将现有约束复制到新对象

iphone - UIImagePNGRepresentation() 返回不同的字节

ios - UISearchBar 背景外观

iphone - 如何计算 CATextLayer 字符串的边界框?

php - iPhone 应用程序用户标识符

ios - 更改 UITextField 占位符字体

iphone - NSString * 到 Char[] (GameCenter Send Struct)

ios - Swift 中 Google Analytics 异常跟踪的正确语法是什么?