what is the difference between UIInterfaceOrientationMaskPortrait and UIInterfaceOrientationPortrait

妖精的绣舞 提交于 2019-12-08 17:05:40

问题


I have looked at documentation but cannot find why sometimes the word mask is inserted and sometimes not.


回答1:


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.



来源:https://stackoverflow.com/questions/13136673/what-is-the-difference-between-uiinterfaceorientationmaskportrait-and-uiinterfac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!