2

I have a UITableViewController that works in both portrait and landscape. From this controller I push another view controller on to the navigation controller. This new viewController is portrait only.

The problem is that when I am in landscape and push the view controller the new viewcontroller is in landscape as well until I rotate it to portrait. Then it's stuck in portrait as it should be.

Is it possible to always make it appear in portrait? Even if its parent is pushing it in landscape?

Update:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Linus
  • 2,799
  • 3
  • 29
  • 43

2 Answers2

1

In viewWillAppear: after statusbar orientation change put this:

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

Hopefully it will help!

P.S.Tested on sdk 3.2.5 ios 5.0.1.

Guntis Treulands
  • 4,764
  • 2
  • 50
  • 72
-1

In your viewWillAppear: use the following code:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • @WrightCS thank you but that only rotates the status bar... The rest of the view is still in landscape – Linus May 31 '11 at 19:08
  • Your view should rotate either way. What do you have in `shouldAutorotateToInterfaceOrientation:`? – WrightsCS May 31 '11 at 19:27
  • Okay, then place `setStatusBarOrientation:` in `viewWillDisappear:` in your landscape controller. – WrightsCS May 31 '11 at 20:28
  • 1
    @Linus Did you find a solution to your problem ? I've got the exactly same problem here and I can't find a solution. – klefevre Apr 17 '13 at 18:50