I have videos throughout my app. Some using MPMoviePlayerController, others in a UIWebView with YouTube. I want my app to be totally portrait. However, I want to give the user the option to flip to landscape when there's a video (not force, but optional).
I've been searching the web for an answer, but I haven't found anything yet.
Thanks for your help!
I had the same issue and fixed it by adding this in my app delegate, basically allowing Landscape orientation only on subclasses of MPMoviePlayerViewController:
#import <MediaPlayer/MediaPlayer.h>
@implementation UIViewController (orientationFix)
-(NSUInteger) supportedInterfaceOrientations
{
if ([[self class] isSubclassOfClass:[MPMoviePlayerViewController class]]) {
return UIInterfaceOrientationMaskLandscape;
}
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
if ([[self class] isSubclassOfClass:[MPMoviePlayerViewController class]]) {
return UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight;
}
return UIInterfaceOrientationPortrait;
}
@end
@implementation MyAppDelegate
.
.
.
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With