Unable to detect boot orientation - iPad

I have a lot of different questions and for some reason I still can't get the iPad to track the orientation on boot.

It seems that the best way to do it is to detect the status of the BarOrientation:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"View Loads");

    if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft
        || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"This is Landscape"); 
    } else {
        NSLog(@"This is Portrait"); 
    }
}

      

But he always returns "Portrait". I have all 4 orientations available in my .plist and shouldAutorotateToInterfaceOrientation as well:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
                interfaceOrientation == UIInterfaceOrientationLandscapeRight || 
                interfaceOrientation == UIInterfaceOrientationPortrait);        
        } else {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
}

      

Does anyone have any other advice? Thanks in advance!

+3


source to share


1 answer


iPad apps always launch in portrait mode, regardless of the actual device orientation (they then immediately rotate to landscape if that device is turned on). If you check the orientation of the status bar later in the lifecycle of a program with the same code, you can see that it returns the actual orientation.



+4


source







All Articles