IOS 6 MPMoviePlayerViewController and presentMoviePlayerViewControllerAnimated Rotation

In previous versions of iOS, our video automatically rotated, but in iOS 6 this is no longer the case. I know that thisMoviePlayerViewControllerAnimated was designed for this before, but how can I say that MPMoviePlayerViewController automatically rotates?

MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; [self presentMoviePlayerViewControllerAnimated:moviePlayer]; 
+4
source share
4 answers

In appdelegate.m:

 - (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[self.window.subviews.lastObject class].description isEqualToString:@"MPMovieView"]) { return UIInterfaceOrientationMaskAllButUpsideDown; } else { return UIInterfaceOrientationMaskPortrait; } } 

Come up with a hack, but it works well ...

+10
source

I ran into the same problem. James Chen's solution is correct, but I ended up doing something a little simpler, which also works - an overriding application: supportedInterfaceOrientationsForWindow in my delegate deletion and returning allButUpsideDown if my rootView controller was modally represented by MPMoviePlayerViewController. In truth, it’s hacky and may not suit all situations, but I managed to change all my view controllers:

 - (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return [rootViewController.modalViewController isKindOfClass:MPMoviePlayerViewController.class ] ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskAllButUpsideDown; } 
+6
source

This is not limited to MPMoviePlayerViewController . From iOS 6, autorotation has been changed. see Autorotation in iOS 6 has strange behavior .

For the application to look like pre-iOS 6, you must make the application support all orientations (edit the UISupportedInterfaceOrientations in plist), then for all other view controllers that do not support rotation, redefine this method to return NO:

 - (BOOL)shouldAutorotate { return NO; } 

By default, MPMoviePlayerViewController supports all orientations, so this should be enough to make it work.

+4
source

I see that in iOS 6 there are a lot of similar messages oriented to the application. But overall the solution is pretty simple: fooobar.com/questions/110247 / ...

+1
source

Source: https://habr.com/ru/post/1436269/


All Articles