视频按钮位于导航栏的ViewController中,按下后,它将立即以纵向模式显示视频。如果我手动旋转它,它只会在风景中。如何在按下按钮后立即以横向模式查看视频?我需要ViewController处于纵向模式,只有视频处于横向模式。如何将视频自动旋转到横向?
这是ViewController.m文件:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(IBAction)backbutton
{
ChapterTableViewController *chapterTable = [self.storyboard instantiateViewControllerWithIdentifier:@"chapterTable"];
[self.navigationController presentModalViewController:chapterTable animated:YES];
}
-(IBAction)playvideo
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"One Piece Episode 180" ofType:@"mp4"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}
@end
我试过使用方法,但它不工作。 – icee 2012-07-10 05:50:08
查看编辑答案 – 2012-07-10 06:17:46
它会变成横向模式,但视频仍处于纵向模式。 – icee 2012-07-10 06:30:06