iPhone Prevent application to automatically change

2019-07-29 12:31发布

问题:

My application is in landscape mode and I use MPMoviePlayerController to play an sample video. It works fine but when I stop the video with the OK button (or if I wait until the movie ends), the orientation automatically changes to portrait. Is it possible to keep application in landscape mode when the OK button is pushed ?

I use the followwing code in my main view controller to force landscape mode :

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

回答1:

I think on the MPMoviePlayerPlaybackDidFinishNotification notification you have to set the statusbarorientation back to landscape.