objective-c – MPMoviePlayerController关闭后顶部的消失状态栏

前端之家收集整理的这篇文章主要介绍了objective-c – MPMoviePlayerController关闭后顶部的消失状态栏前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有一个有趣的小问题,我的iPhone应用程序.我有一张桌子和每个单元格的视图,点击时,播放视频全屏,然后按完成后,视频停止并返回到表视图.唯一的问题是,当您在视频加载的前2或3秒内按完成时,当视图返回到表视图时,屏幕顶部显示时间和电池强度等的栏不再在那里,它只是一个空白的空间.但是如果你在头几秒之后按下完成,那么当你回到桌面视图时,一切都是绝对好的!我完全不知道为什么会发生这种情况,我在互联网上发现的唯一的事情是这是一个与我完全一样的问题的人:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/53020-disappearing-status-bar.html

这导致我尝试使用:

[UIApplication sharedApplication].statusBarHidden = NO;

但是,这也无济于事.

点击视频时执行的代码

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];

视频完成或用户点击完成后执行代码是:

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;

如果有人可以在这种情况下轻视,我将非常感激,因为这是非常令人沮丧的!

谢谢,

马特

解决方法

视频视图消失时的动画可能会导致状态栏动画的时序问题.

尝试延迟statusBarHidden = NO调用几秒钟.

NSInteger delay = 3;

dispatch_after(dispatch_time(DISPATCH_TIME_NOW,delay * NSEC_PER_SEC),dispatch_get_current_queue(),^{
[UIApplication sharedApplication].statusBarHidden = NO;
});
原文链接:https://www.f2er.com/c/112561.html

猜你在找的C&C++相关文章