【发布时间】:2011-08-02 07:46:45
【问题描述】:
我的 MPMoviePlayerController 视图作为子视图添加到另一个视图控制器的视图中。当我全屏播放视频并翻转模拟器时,视频不翻转,父视图也不翻转。但是,当我在旋转方法中添加return YES 时(检查下面的代码),视频在全屏时旋转,但父视图也会旋转,这是我不想要的,因为我没有设计父视图的横向视图。当视频全屏而不是父视图时,如何仅允许视频旋转??
这是我使用的代码:
对于视频:
- (void)viewDidAppear:(BOOL)animated {
NSBundle *bundle=[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"MainPageMovie" ofType:@"mp4"];
NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.view.frame = CGRectMake(115.0, 156.0, 200.0, 150.0);
[self.view addSubview:theMovie.view];
[theMovie play];
[super viewDidLoad];
self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
}
对于旋转方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return YES;
}
【问题讨论】: