Note that there are some explanatory texts on larger screens.

plurals
  1. POUITabBar identifying portrait or landscape orientation
    primarykey
    data
    text
    <p>While, for the most part, orientation is working properly for my app, I'm having an issue testing on my iPad 1. If I have the device tipped at a relatively low angle, there are times while navigating through the tabs that the tab bar appears in landscape mode, but the page calls a portrait mode uiview and then tries to render it in landscape mode, screwing up my UI.</p> <p>I'm trying to figure out if there is a method to lock down "if the tab bar appears in landscape mode, always call the landscape UIViews and if in portrait mode, always call the portrait UIView."</p> <p>On each view controller I've set the following:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // iPad-specific condition here if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)){ self.view = self.portraitViewiPad; } else { self.view = self.landscapeViewiPad; } } } -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { // iPad-specific condition here if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { //show portrait XIB here self.view = self.portraitViewiPad; } else { //show landscape XIB here self.view = self.landscapeViewiPad; } } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // iPad-specific interface here return YES; } else { // For iPhone and iPod touch interface return (interfaceOrientation == UIInterfaceOrientationPortrait); } } </code></pre> <p>I've also adjusted the app delegate using the method below thinking that could address the issue:</p> <pre><code>- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{ //CALLS RELOAD METHODS HERE AND EACH UIVIEW IS PROPERLY BEING CALLED } </code></pre> <p><strong>UPDATE:</strong></p> <p>Corrected this issue by checking the orientation of the status bar and displaying the correct uiview accordingly. Here's how I updated my viewDidLoad methods:</p> <pre><code>if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationLandscapeLeft){ NSLog(@"Left landscape detected"); self.view = self.landscapeViewiPad; } else if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationLandscapeRight){ NSLog(@"Right landscape detected"); self.view = self.landscapeViewiPad; } else if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait){ NSLog(@"Portrait orientation detected"); self.view = self.portraitViewiPad; } else if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown){ NSLog(@"Upsidedown Portrait detected"); self.view = self.portraitViewiPad; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload