iOS MPMoviePlayerViewController视频播放横屏,隐藏状态栏

MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc] init];

moviePlayerViewController.view.frame = CGRectMake(0, 0, self.view.bounds.size.height, self.view.bounds.size.width);

moviePlayerViewController.view.center = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2);

CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI/2);

[moviePlayerViewController.view setTransform:transform];

[self.view addSubview:moviePlayerViewController.view];

如果需要放大可以设置 moviePlayerViewController.scalingMode 属性,有4种可选。

你会发现系统状态栏会随着屏幕旋转,这时候最好的方法是将其隐藏

在viewWillAppear:里[[UIApplication sharedApplication] setStatusBarHidden:YES];

viewDidDisappear:里[[UIApplication sharedApplication] setStatusBarHidden:NO];

隐藏状态栏记得在plist中添加有关的Key,不然隐藏不会生效.详见我的另一篇简文.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容