Set*_*lue 15 iphone statusbar mpmovieplayercontroller ipad
我整天都在努力解决一个非常烦人的问题,我希望能在这个板上找到帮助.
我正在使用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);
}
Run Code Online (Sandbox Code Playgroud)
在控制台中,我可以看到moviePlayerEvent在电影出现但状态栏仍然存在时被触发:[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO]似乎是无效的.我一直试图使用其他MPMoviePlayerController通知,没有运气.
那个人可以帮助我吗?
提前致谢.
rcw*_*cw3 22
不幸的是,在遇到这个问题之后,通过研究和大量实验,我已经确定在全屏模式下隐藏iOS状态栏几乎是不可能的.无论你做什么,当显示全屏播放器控件时,状态栏也会显示(它不会尊重setStatusBarHidden:YES
).嵌入式播放器控件不是这种情况,但用户可以在嵌入式和全屏模式之间轻松切换,因此在显示控件时,您无法真正使用它来保持状态栏.
当然,当控件淡出时,状态栏至少会消失......
不要将电影播放器的视图添加到主视图中; 相反,如下所示以模态方式呈现电影播放器(为简洁/清晰而省略了一些步骤):
moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
// Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerViewController.moviePlayer];
//Present
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];
// Play the movie!
self.moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[self.moviePlayerViewController.moviePlayer play];
// When the movie is done, release the controller.
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
//NSLog(@"playback terminated");
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerViewController.moviePlayer];
[moviePlayerViewController release], moviePlayerViewController = nil;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19409 次 |
最近记录: |