Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a nice workaround for this problem. The clue is to support <em>all</em> orientations for <em>all</em> views in <code>UINavigationController</code>.</p> <p>I've got 2 views in controller. Root view is to support only <code>LandscapeRight</code>, and second supports both <code>LandscapeRight</code> and <code>Portrait</code>.</p> <p>Second view <code>shouldAutorotateToInterfaceOrientation</code> method looks as usual: </p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationPortrait); } </code></pre> <p>The workaround itself is contained in Root view source Now the root view rotates in terms of code, but the user cant see it.</p> <pre><code>//auxiliary function -(void) fixOrientation:(UIInterfaceOrientation)orientation { if (orientation == UIInterfaceOrientationPortrait) self.view.transform = CGAffineTransformMakeRotation(M_PI_2); else if (orientation == UIInterfaceOrientationLandscapeRight) self.view.transform = CGAffineTransformMakeRotation(0); } -(void) viewWillAppear:(BOOL)animated { [self fixOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { [self fixOrientation:interfaceOrientation]; //notice, that both orientations are accepted return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationPortrait); } //these two functions helps to avoid blinking - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [UIView setAnimationsEnabled:NO]; // disable animations temporarily } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [UIView setAnimationsEnabled:YES]; // rotation finished, re-enable them } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      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