MPMoviePlayerViewControllerIOS6下实现横屏播放
2013-06-05 17:20
429 查看
今天遇到一个MPMoviePlayerController无法横屏的问题,之前好像遇到过这个问题,但是好久不弄忘记了,那时候也是在IOS5.X下面做的 如果是IOS5.X不考虑IOS6的情况下,可以用这个方法http://blog.csdn.net/mideveloper/article/details/9031081
但是IOS6对横竖屏切换进行了调整,采用了两个新的方法,详细看这篇文章http://blog.csdn.net/starryheavens/article/details/8396045
顺便摘录之
发现 b2c交易在ios6上webview随屏幕旋转了,但是b2c支持横屏的,原因是ios6的委托
iOS6下的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
这个不会再被调用,取而代之的是这俩个组合:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
当然,为了保持对旧版本系统行为的兼容性,不要删掉不用的那个调用。另外还有一个这个preferred朝向也可以加上
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
b2c交易只支持横屏,网银交易需要支持横竖屏,所以如果在info.plist设置支持的方向,则再同以客户端下两种应用有冲突。解决这个问题的方法就是再前面的基础上再应用的delegate中加入如下回调:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (clientstate == 0) /* 网银*/
return UIInterfaceOrientationMaskAll;
else/* b2c*/
return UIInterfaceOrientationMaskLandscape;
}
简单说明:
UIInterfaceOrientationMaskLandscape 支持左右横屏
UIInterfaceOrientationMaskAll 支持四个方向旋转
UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown以外的旋转
所以如果是IOS6的话,可以这样实现,创建一个类,继承自MPMoviePlayerViewController
然后在AppDelegate.m中添加如下代码
搞定
但是IOS6对横竖屏切换进行了调整,采用了两个新的方法,详细看这篇文章http://blog.csdn.net/starryheavens/article/details/8396045
顺便摘录之
发现 b2c交易在ios6上webview随屏幕旋转了,但是b2c支持横屏的,原因是ios6的委托
iOS6下的
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
这个不会再被调用,取而代之的是这俩个组合:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
当然,为了保持对旧版本系统行为的兼容性,不要删掉不用的那个调用。另外还有一个这个preferred朝向也可以加上
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
b2c交易只支持横屏,网银交易需要支持横竖屏,所以如果在info.plist设置支持的方向,则再同以客户端下两种应用有冲突。解决这个问题的方法就是再前面的基础上再应用的delegate中加入如下回调:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (clientstate == 0) /* 网银*/
return UIInterfaceOrientationMaskAll;
else/* b2c*/
return UIInterfaceOrientationMaskLandscape;
}
简单说明:
UIInterfaceOrientationMaskLandscape 支持左右横屏
UIInterfaceOrientationMaskAll 支持四个方向旋转
UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown以外的旋转
所以如果是IOS6的话,可以这样实现,创建一个类,继承自MPMoviePlayerViewController
VideoPlayerViewController.h
#import <MediaPlayer/MediaPlayer.h> @interface VideoPlayerViewController : MPMoviePlayerViewController @end
VideoPlayerViewController.m
#import "VideoPlayerViewController.h" @implementation VideoPlayerViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIDeviceOrientationIsLandscape(interfaceOrientation); } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window { return UIInterfaceOrientationMaskAllButUpsideDown; } @end
然后在AppDelegate.m中添加如下代码
//为了MPMoviePlayerViewController保持横平 - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window { return UIInterfaceOrientationMaskAllButUpsideDown; }
搞定
相关文章推荐
- MPMoviePlayerViewController实现横屏播放
- MPMoviePlayerViewController实现横屏播放
- iOS开发--利用MPMoviePlayerViewController播放视频简单实现
- MPMoviePlayerViewController播放视频横屏播放
- 利用MPMoviePlayerViewController实现简单的mp4播放
- [基础]MPMoviePlayerViewController实现MP4播放
- MPMoviePlayerViewController的自动横屏播放
- MPMoviePlayerViewController视频播放
- 用 MPMoviePlayerController 实现简单的视频下载播放功能
- ios MPMoviePlayerViewController播放结束时的回调方法
- iOS6下慎用MPMoviePlayerViewController!
- 使用封装号的MPMoviePlayerViewController播放MP4视频
- 让MpMoviePlayerViewController播放时自动横屏
- IOS MPMoviePlayerViewController视频播放(MediaPlayer)
- kidd风的IOS日志之播放音乐(MPMoviePlayerViewController和MPMoviePlayerController)
- 视频播放--MPMoviePlayerViewController
- MPMoviePlayerViewController 播放本地视频一直loading
- iOS7的程序加了多个UIWindow,调用MPMoviePlayerViewController播放视频时,除了key window其他window的坐标会被改变,怎么办
- MPMoviePlayerViewController 视频播放黑屏
- 使用MPMoviePlayerViewController播放视频--