Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually set interface orientation

Tags:

ios

ios4

ios-4.2

Is there any easy way to manually set the orientation of an interface? I need to set the interface to portrait even though the device orientation might be in landscape during loading. Kinda want to stay away from CGAffineTransforms.

like image 700
brad_roush Avatar asked Dec 01 '22 07:12

brad_roush


1 Answers

One method I know that works for me (and is a bit of a hack and can display one orientation before changing to the orientation you want) is:

- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];

    UIApplication* application = [UIApplication sharedApplication];

    if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
    {
        UIViewController *c = [[UIViewController alloc]init];
        [self presentModalViewController:c animated:NO];
        [self dismissModalViewControllerAnimated:NO];
        [c release];
    }
}
like image 122
Shane Powell Avatar answered Dec 06 '22 01:12

Shane Powell