Mat*_*att 9 objective-c statusbar mpmovieplayercontroller
我的iPhone应用程序有一个有趣的小问题.我有一个带有桌子的视图,每个单元格在单击时播放全屏视频,然后当您按完时,视频停止并返回到表格视图.唯一的问题是,当您在视频加载的前2或3秒内完成按下时,当视图返回到表格视图时,屏幕顶部的条形图将告知时间和电池强度等不再那里,它只是一个白色的空间.但是如果你在前几秒后按完了,那么当你回到表视图时,一切都绝对没问题!我完全不知道为什么会这样,我在互联网上找到的唯一一件事就是这个人和我的问题几乎完全相同:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/53020-disappearing-status-bar.html
这导致我尝试使用:
[UIApplication sharedApplication].statusBarHidden = NO;
Run Code Online (Sandbox Code Playgroud)
然而,这也没有任何意义.
点击视频时执行的代码:
NSString *path = [[NSBundle mainBundle] pathForResource:currentTitle ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:path];
movieController = [[MPMoviePlayerController alloc] initWithContentURL:url];
[movieController setControlStyle:MPMovieControlStyleFullscreen];
[movieController setFullscreen:YES];
movieController.view.frame = self.view.bounds;
[self.view addSubview:movieController.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
Run Code Online (Sandbox Code Playgroud)
在视频完成或用户点击完成时执行的代码是:
NSLog(@"movieController moviePlayBackDidFinish");
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[movieController setFullscreen:NO animated:NO];
[movieController.view removeFromSuperview];
[movieController release];
LiveEventsView *liveEventsView = [[LiveEventsView alloc] initWithNibName:@"LiveEventsView" bundle:nil];
UIView *currentView = self.view;
UIView *theWindow = [currentView superview];
UIView *newView = liveEventsView.view;
newView.frame = CGRectMake(0, 20, 320, 460);
[currentView removeFromSuperview];
[theWindow addSubview:newView];
[UIApplication sharedApplication].statusBarHidden = NO;
Run Code Online (Sandbox Code Playgroud)
如果有人能够对这种情况有所了解,我将非常感激,因为它非常令人沮丧!
谢谢,
马特
也许从视频视图消失时的动画导致状态栏动画的计时问题.
尝试延迟statusBarHidden = NO呼叫几秒钟.
NSInteger delay = 3;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
[UIApplication sharedApplication].statusBarHidden = NO;
});
Run Code Online (Sandbox Code Playgroud)
您可以将延迟设置为浮点数.所以它会
float delay = 0.1;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
[UIApplication sharedApplication].statusBarHidden = NO;
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
});
Run Code Online (Sandbox Code Playgroud)
我有同样的问题,并通过修改richerd的代码解决了它.0.1秒是可以接受的.我还必须更改状态栏样式,因为它返回了BlackTranslucent栏样式,而原始样式是BlackOpaque样式.但现在工作正常.
| 归档时间: |
|
| 查看次数: |
5276 次 |
| 最近记录: |