Pages

Saturday, May 19, 2012

iPhone screen rotation logic

This is the proper implementation for screen rotation (example is portrait or upside down portrait);

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
            if ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation
            ==UIInterfaceOrientationPortraitUpsideDown)) {   
                 return YES;
             } else {
                 return NO;
    }
}
the other possible states are UIInterfaceOrientationLandscapeLeft or UIInterfaceOrientationLandscapeRight.

You should also set the view mode in the view's Attribute inspector on the storyboard.