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.