我有两个视图控制器。一个视图有按钮,当用户单击该按钮时,他将重定向到存在 MPMoviePlayer 控制器的另一个视图。我想默认情况下将 MPMoviePlayer 控制器视图显示为 LandsapeRight 模式。
我在 buttonAction 中写了下面的代码
-(void)buttonAction
{
tLive = [[toneTvlive alloc]init];
[self.navigationController pushViewController:tLive animated:YES];
}
在第二个视图中我写了下面的代码
- (void)viewDidLoad
{
[super viewDidLoad];
printf("\n hii");
self.navigationController.navigationBar.hidden = YES;
[[UIApplication sharedApplication]setStatusBarHidden:NO];
NSURL *mediaURL = [NSURL URLWithString:@""];
mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
//[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setMovieSourceType:MPMovieSourceTypeStreaming];
[mp setFullscreen:YES animated:YES];
[mp.view setFrame: CGRectMake(0,0, 480,320)];
[self.view addSubview:mp.view];
[mp prepareToPlay];
[mp play];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
首先运行程序时,它仅以纵向模式显示视图。它不会提示视图以横向旋转,但是当我旋转设备后它工作正常。谁能帮我解决这个问题。