Note that there are some explanatory texts on larger screens.

plurals
  1. PO[UIDevice currentDevice].orientation == UIDeviceOrientationUnknown following UINavigationController push
    text
    copied!<p>This is an observation more than anything, because I appear to have found a work-around...</p> <p>The code below fails to work <em>when it's in a controller which has been pushed onto a UINavigationController stack</em>. In this situation <code>[UIDevice currentDevice].orientation</code> consistently returns <code>UIDeviceOrientationUnknown</code>. </p> <pre><code>-(void)layoutAccordingToOrientation { UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; NSLog(@"layoutAccordingToOrientation/orientation==%i", orientation); if (UIInterfaceOrientationIsLandscape(orientation)) { : _detailToolbar.frame = CGRectMake(0, 660, 1024, 44); } else { : _detailToolbar.frame = CGRectMake(0, 916, 768, 44); } } -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self layoutAccordingToOrientation]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } </code></pre> <p>The following call <em>has</em> been made:</p> <pre><code>[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; </code></pre> <p>To work around this <code>UIDeviceOrientationUnknown</code>-problem, I now use the following instead:</p> <pre><code>UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if (UIInterfaceOrientationIsLandscape(orientation)) { etc. } else { etc. } </code></pre> <p>... which works every time.</p> <p>Still, I fail to see why the first variation would not work in the context of a pushed view controller. Ideas anyone? Is it simply a bug?</p>
 

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