Question

In navigation controllers, one screen has the ability to play a video, being able to be viewed in both portrait and landscape, and then upon completion a new view controller is pushed in the navigation controller, but I ONLY want to show in portrait.

I've tried using

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

before AND after the segue, but that doesn't work for me. The status bar is there but the view draws itself in landscape format.

Any ideas how to fix this?

Thanks!

[UPDATED] None of the work-arounds ended up working, so I ended up just presenting it modally until I can find a better solution.

Thanks for the answers!

Was it helpful?

Solution 3

None of the work-arounds ended up working, so I ended up just presenting it modally until I can find a better solution.

Thanks for the answers!

(Also added to original post)

OTHER TIPS

Im a little confused by your question, but if I understand correctly, you want to prevent the view from displaying in landscape. Add this method to your view controller's implementation file:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

That particular view controller will then only run in portrait. Is that what you wanted?

I did some research on this issue, because I remember having the same problem in a project I worked on two years ago. Back then we solved it by having all our controllers support both orientations, because it was easier to just have them support landscape than to force portrait.

Unfortunately it doesn't seem like much have changed since then. It still seems to be an open issue, with no documented way to fix it. However I did find a few workarounds that I think will work for you:

  1. Present and dismiss a modal view controller:

    UIViewController *c = [[UIViewController alloc] init];
    [self presentModalViewController:c animated:NO];
    [self dismissModalViewControllerAnimated:NO];
    [c release];
    
  2. Rotate the view manually.

  3. Push and pop a view controller before pushing the real view controller.

All methods have been reported to work, but I haven't tested them. You'll find the code and more methods here: Is there a documented way to set the iPhone orientation?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top