视频按钮位于导航栏的 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