Note that there are some explanatory texts on larger screens.

plurals
  1. POsetStatusBarOrientation issue
    primarykey
    data
    text
    <p>I have a navigation controller app. And first I push FirstViewController (support Portrait orientation) and then SecondViewController (supports all orientations). When I'm in landscape mode of SecondViewController and press back button, FirstViewController appears in landscape mode. That's why I manually rotate the navigation view, but when I want to set setStatusBarOrientation to Portrait (First view controller should appears only in portrait mode), the orientation of view controller is still landscape, and even if rotate the device to portrait mode, the orientation stay landscape .Here is my code of FirstViewController:</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { prevInterfaceOrientation = UIInterfaceOrientationLandscapeLeft; self.navigationController.view.transform = CGAffineTransformIdentity; self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90)); } else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) { prevInterfaceOrientation = UIInterfaceOrientationLandscapeRight; self.navigationController.view.transform = CGAffineTransformIdentity; self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(-90)); } [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; [self.tableViewDetail reloadData]; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { if (prevInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { self.navigationController.view.transform = CGAffineTransformIdentity; } else if (prevInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { self.navigationController.view.transform = CGAffineTransformIdentity; } [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; [self.tableViewDetail reloadData]; } } </code></pre> <p>I even tried to use:</p> <pre><code>- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { if (UIInterfaceOrientationIsLandscape(prevInterfaceOrientation)) { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; } } </code></pre> <p>but self.interfaceOrientation still stays landscape, when I rotate to portrait. But I really need to rotate the view to portrait mode manually to allow users to see,that FirstViewController suppors only portrait orientation. I have the option to put the SecondViewController's view on MainWindow (like modal window), but I don't like this idea, because if apple has setStatusBarOrientation method, it seems to me, that it has to be right solve of this issue.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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