让MpMoviePlayerViewController播放时自动横屏
来源:互联网 发布:python游戏开发平台 编辑:程序博客网 时间:2024/05/19 05:05
网上有很多关于MpMoviePlayerViewController播放时自动横屏的教程,但试用了好些个也不行.总结过后得出以下方法:
首先,在AppDelegate.m文件中,加入:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {//UIInterfaceOrientationMaskLandscape 支持左右横屏//UIInterfaceOrientationMaskAll 支持四个方向旋转//UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown以外的旋转return UIInterfaceOrientationMaskAllButUpsideDown;}
再写一个继承自MPMoviePlayerViewController的类:
//// MyMoviePlayViewController.h// Medicine//// Created by Jz on 14-3-17.// Copyright (c) 2014年 Jz. All rights reserved.////重写MpMoviePlayerController类 实现自动横屏#import <MediaPlayer/MediaPlayer.h>@interface MyMoviePlayViewController : MPMoviePlayerViewController@end在MyMoviePlayViewController.m中:
MyMoviePlayerViewController.m- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return UIDeviceOrientationIsLandscape(interfaceOrientation);}- (BOOL)shouldAutorotate{ return YES;}- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscape;}- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window{ return UIInterfaceOrientationMaskAllButUpsideDown;}最后:
#import "MyMoviewPlayViewController"..........MyMoviePlayViewController *playerVC = [[MyMoviePlayViewController alloc] initWithContentURL:XXXXXXX];[self presentMoviePlayerViewControllerAnimated: playerVC];
这样 在播放的时候,自动就会跳转为横屏.并且返回后跳回竖屏.
0 0
- 让MpMoviePlayerViewController播放时自动横屏
- MPMoviePlayerViewController的自动横屏播放
- MPMoviePlayerViewController实现横屏播放
- MPMoviePlayerViewController实现横屏播放
- MPMoviePlayerViewController播放视频横屏播放
- MPMovieplayerviewcontroller播放结束后自动消失的解决方案
- MPMovieplayerviewcontroller播放结束后自动消失的解决方案
- 使用MPMoviePlayerViewController播放视频
- MPMoviePlayerViewController电影播放器
- 使用MPMoviePlayerViewController播放视频--
- iOS 视频播放 MPMoviePlayerViewController
- MPMoviePlayerViewController视频播放
- MPMoviePlayerViewController视频播放
- iOS 视频播放 MPMoviePlayerViewController
- MPMoviePlayerViewController播放在线视频
- 视频播放MPMoviePlayerViewController
- 视频播放--MPMoviePlayerViewController
- 视频播放MPMoviePlayerViewController
- 创建代理类实例的三种方法
- unity3d遍历子对象的几种方法
- 【QT】2-[new]Qt4.8.5+VS2010+Addin配置
- Android基本组件及声明周期介绍
- 好句摘录
- 让MpMoviePlayerViewController播放时自动横屏
- FCKeditor使用方法技术详解
- SD卡的初始化操作
- gf_file_from_blob(blob blob1,string file1) pb大字段生成文件方法
- 第一次写WCF遇到的几个问题
- Android页面转换的两种方式
- Eclipse安装SVN插件
- 对话框类调用视图类并绘图(基于MFC)
- POJ 2923 Relocation / 状态压缩DP