我整天都在为一个非常烦人的问题而苦苦挣扎,我希望我能在这个板上找到帮助。
我正在使用 MPMoviePlayerController 在 iPad 上播放全屏电影,但我不知道如何删除始终显示的状态栏,尽管我竭尽全力让它下地狱。
这是我用来显示电影的方法的代码:
-(void)launchVideoFromButton:(id)sender{
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"movie01" ofType:@"m4v"];
NSURL *videoPathURL = [NSURL fileURLWithPath:videoPath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoPathURL];
[self.view addSubview:moviePlayer.view];
moviePlayer.shouldAutoplay = YES;
moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[moviePlayer setFullscreen:YES animated:YES];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(moviePlayerEvent:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];
}
-(void)moviePlayerEvent:(NSNotification*)aNotification{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
NSLog(@"%i", [UIApplication sharedApplication].statusBarHidden);
}
在控制台中,我可以看到当电影出现但状态栏仍然存在时,moviePlayerEvent 被触发: [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO] 似乎无法操作。我一直在尝试使用其他 MPMoviePlayerController 通知,但没有成功。
谁能帮我解决这个问题?
提前致谢。