【发布时间】:2015-01-05 14:01:38
【问题描述】:
在 MPMovieplayer 中有太多与横向问题相关的问题。我的应用程序处于纵向模式。但我想要横向模式的视频。我已经有视频的横向/纵向功能。我正在使用以下代码:
static NSString * const VIDEO_CONTROLLER_CLASS_NAME_IOS7 = @"MPInlineVideoFullscreenViewController";
static NSString * const VIDEO_CONTROLLER_CLASS_NAME_IOS8 = @"AVFullScreenViewController";
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if ([[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(VIDEO_CONTROLLER_CLASS_NAME_IOS7)] ||
[[window.rootViewController presentedViewController] isKindOfClass:NSClassFromString(VIDEO_CONTROLLER_CLASS_NAME_IOS8)])
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
else {
return UIInterfaceOrientationMaskPortrait;
}
}
代码在 iOS 7 和 iOS8 中都可以正常工作。 但问题是,当设备处于横向模式时,视频首先以纵向模式打开。改变方向后,应用可以正常工作。
提前致谢。
【问题讨论】:
-
有什么方法可以手动调用以下方法:- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 或任何其他方式手动更新 mpmovieplayer 的方向。所以它会解决我的问题。
-
你能试试下面的代码吗,[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; [[自拍] setBounds:CGRectMake(0, 0, 480, 320)]; [[自拍] setCenter:CGPointMake(160, 240)]; [[自拍] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];播放视频时放置上面的代码。以上代码适用于 iPhone 4 屏幕尺寸,请根据您的设备屏幕尺寸更改值。
-
@sundeep 我在触发视频开始通知时将上述代码添加到该方法中。但运气不好,它在我的最后不起作用。视频屏幕不旋转。
标签: ios ios8 mpmovieplayercontroller mpmovieplayer xcode6.1