Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between UIInterfaceOrientationMaskPortrait and UIInterfaceOrientationPortrait

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

like image 378
Steblo Avatar asked Oct 30 '12 10:10

Steblo


1 Answers

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.

like image 85
rich.e Avatar answered Nov 05 '22 16:11

rich.e