gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 03:13:38 26 4
gpt4 key购买 nike

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

最佳答案

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com