- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的应用程序支持的界面方向是纵向和颠倒。但是,当播放视频时,我希望它能全屏横向播放。目前使用此代码,即使设备旋转,它也只能播放纵向:
[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self presentMoviePlayerViewControllerAnimated:player];
我怎样才能强制它进入横向模式?
最佳答案
这是我的做法:
在项目文件中,确保您支持景观方向
现在,在所有仍应为 Portrait Only 的 ViewController 中,添加此代码
//ios6
- (BOOL)shouldAutorotate {
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
//ios4 and ios5
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
我已经加入了 iOS5 和 iOS6 调用,这样我的代码就可以在两者上运行。
当您的 MPMoviePlayerController View 变为全屏时,它将是一个新的 ViewController,位于其他所有 View 之上。因此,它可以根据项目支持的界面方向进行旋转。它不会看到您在哪里强制其他 ViewControllers 进入纵向。
关于ios - 如何在仅纵向应用程序中使用 MPMovieViewController 播放横向视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13021520/
我有一个通过 MPMoviePlayerViewController 播放视频的应用程序,该应用程序在 UITableViewController 上执行选择操作后呈现,该 UITableViewCo
我是 Swift 新手我正在使用 MPMovieviewcontroller当我单击下一个或上一个按钮时,没有事件发生这是代码 import UIKit import MediaPlayer clas
我的应用程序支持的界面方向是纵向和颠倒。但是,当播放视频时,我希望它能全屏横向播放。目前使用此代码,即使设备旋转,它也只能播放纵向: [player.moviePlayer setControlSty
我正在为 IOS7 创建一个 xcode 应用程序,它在大多数 View 中以纵向模式工作。 项目设置允许“Portrait”“Landscape Left”和“Landscape Right”。 在
我是一名优秀的程序员,十分优秀!