views:

700

answers:

2

So, I'm putting some controls over an MPMoviePlayerController and I'm intending this to be used in portrait mode, simply by using video that is shot vertically. My only problem is that for text entry the keyboard comes up in landscape.

Now, I realize that there is an undocumented way to set the orientation of the player, but I'd rather not try this and get rejected at the app store. (FYI this is it):

[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; // not legal?

I've tried overriding the autorotate method in my view controller:

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

but it once the movie player starts playing it takes over and doesn't respect this.

I'm just wondering if anyone has any other ideas on a legal way to keep the keyboard in portrait even while the movie player wants to take the system to landscape.

thanks, Pat

+2  A: 

When the iPhone is rotated, the "top level" view is sent the notification, and that view is responsible for laying out its subviews.

If your UIWebView is the top level view, it will autorotate itself. However, if you put the UIWebView inside of another view, and have the view controller for that "container" view implement the shouldAutorateToInterfaceOrientation method like this:

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

That would probably prevent the UIWebView from knowing the interface was rotated. Note that I haven't actually tried this, but it should would work.


From this SO article

Chris Ballance
I'm sure this is good info in general, but as for this problem the MPMoviePlayerController view is out of our hands and it gets pushed onto the window by the OS when you select [moviePlayer play]. The only apparently legal solution that I have found is, immediately after starting play, to set the status bar orientation: [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationPortrait animated:NO]; and that quickly shifts it back to portrait. I'll have to take this farther to see how well that holds up.
Pat Niemeyer
A: 

With regard to MPMoviePlayerController There doesn't seem to be a legal way to do this, however please see the workaround I posted above using setStatusBarOrientation.

Pat Niemeyer