简体   繁体   中英

what is the difference between UIInterfaceOrientationMaskPortrait and UIInterfaceOrientationPortrait

我看过文档,但找不到为什么有时插入“掩码”一词,有时却不插入的原因。

UIInterfaceOrientationMask is used by iOS 6's

-[UIViewController supportedInterfaceOrientations]

method ( docs here ), which is a bitmask of all the orientations your view controller will take, called by the sdk. The following is an example implementation:

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

This is in contrast to the pre iOS 6 (now deprecated, docs here ) method:

-[UIViewController shouldAutorotateToInterfaceOrientation:]

which gave you a UIInterfaceOrientation enum value, to which you tested against with something like:

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

Note that you still get the UIInterfaceOrientation enum in the didRotate method as well as the interfaceOrientaiton property, which can be useful at other times. The mask is only used when the sdk is deciding whether to rotate your view controller or not.

Question for others: has anyone noticed there is no UIInterfaceOrientationMaskPortraitAll mask? Seems missing to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM