what is the difference between UIInterfaceOrientationMaskPortrait and UIInterfaceOrientationPortrait

ios, objective-c, xcode4

Solution

`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.

Problem

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

Original source