我有一个动态定义旋转配置的应用程序,因此我无法在项目文件中设置支持的旋转。
因此我必须处理新的shouldRotate方法(感谢Apple !!)
但是尽管已经覆盖了这些并且阻止了完整的UI显示除了肖像之外的任何东西。全屏显示视频视图并旋转时。视频将旋转至风景图。
是否还有另一种方法可以专门从旋转中预览视频?
答案 0 :(得分:0)
这是一个使用MPMoviePlayerViewController
子类的实现,支持纵向和纵向颠倒(但您可以轻松更改掩码)。 这可以在你建议的iOS 6中使用,以前的版本有不同的旋转选择器。
用法:
NSURL* url = [NSURL URLWithString:@"your_movie"];
MovieViewController* mvc = [[MovieViewController alloc] initWithContentURL:url];
// I did this from the app delegate.
// You could push this view controller, present it modally, etc.
[self.window setRootViewController:mvc];
在 MovieViewController.h :
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MovieViewController : MPMoviePlayerViewController
- (id)initWithContentURL: (NSURL*) url;
@end
在 MovieViewController.m :
中#import "MovieViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface MovieViewController ()
@end
@implementation MovieViewController
- (id)initWithContentURL: (NSURL*) url
{
self = [super initWithContentURL: url];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
ROTATION CODE
*/
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
@end
结果(注意项目的旋转已在所有旋转中启用..):