草庐IT

objective-c - UIInterfaceOrientationMaskPortrait 和 UIInterfaceOrientationPortrait 有什么区别

coder 2023-09-21 原文

我查看了文档,但找不到为什么有时会插入单词掩码,有时却不会。

最佳答案

UIInterfaceOrientationMask 由 iOS 6 使用

-[UIViewController supportedInterfaceOrientations]

方法 ( docs here ),它是您的 View Controller 将采用的所有方向的位掩码,由 sdk 调用。以下是一个示例实现:

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape; // supports both landscape modes
}

这与 iOS 6 之前的方法(现已弃用,docs here)形成对比:

-[UIViewController shouldAutorotateToInterfaceOrientation:]

它给了你一个 UIInterfaceOrientation 枚举值,你用类似的东西测试了它:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
   return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}

请注意,您仍然在 didRotate 方法中获得 UIInterfaceOrientation 枚举以及 interfaceOrientaiton 属性,这在其他时候可能很有用。 mask 仅在 sdk 决定是否旋转 View Controller 时使用。

其他人的问题:有没有人注意到没有UIInterfaceOrientationMaskPortraitAll掩码?我好像不见了。

关于objective-c - UIInterfaceOrientationMaskPortrait 和 UIInterfaceOrientationPortrait 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13136673/

有关objective-c - UIInterfaceOrientationMaskPortrait 和 UIInterfaceOrientationPortrait 有什么区别的更多相关文章

随机推荐