tags:

views:

211

answers:

1

When a user moves their iPhone, my views switch appropriately between portrait and landscape mode with no problem using the following code:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait || 
  interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
  interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

The problem is, if they press a button that takes them to another screen after the rotating to landscape, then the next screen goes back to portrait mode and the status bar correctly remains in landscape mode. How do I detect which mode the iPhone currently is in during a onviewload so that i can run the change the change the view orientation appropriately?

+1  A: 

Your view controller is sent this message before device orientation changes:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

toInterfaceOrientation is the state of the application’s user interface orientation after the rotation.

Jane Sales
Thanks Jane,Can I borrow your brain for a week :)
TonyNeallon