視頻按鈕位於導航欄的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