关闭MPMoviePlayerController后,顶部的状态栏消失 [英] Disappearing status bar at the top after MPMoviePlayerController is closed

查看:102
本文介绍了关闭MPMoviePlayerController后,顶部的状态栏消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序有一个有趣的小问题.我有一个带有表的视图,单击每个单元格会全屏播放视频,然后按完成后,视频将停止并返回到表视图.唯一的问题是,当您在视频加载的前2或3秒钟内按完成按钮时,当视图返回到表格视图时,屏幕顶部的时间和电池强度等指示栏将不再显示在那里,它只是一个空白.但是,如果您在开始的几秒钟后按完成,那么当您返回到表格视图时,一切都很好!我完全不知道为什么会这样,而且我在互联网上发现的唯一东西就是这个人,他和我的问题几乎完全相同:

Having an interesting little problem with my iPhone app. I have a view with a table and each cell, when clicked, plays a video fullscreen then when you press done, the video stops and goes back to the table view. The only problem is, when you press done within the first 2 or 3 seconds of the video loading, when the view goes back to the table view, the bar at the top of the screen that tells the time and battery strength etc is no longer there, its just a white space. But if you press done after the first few seconds, then when you go back to the table view, everything is absolutely fine! I have absolutely no idea why this is happening and the only thing I found on the internet is this which is some guy with pretty much exactly the same problem as me:

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

这使我尝试使用:

[UIApplication sharedApplication].statusBarHidden = NO;

但是,这也无济于事.

他们点击视频时执行的代码:

The code that is executed when they click on a video:

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

在视频播放完毕或用户单击完成时执行的代码是:

And the code that executes either when the video is done or when the user clicks done is:

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;

如果有人可以阐明这种情况,我将非常感激,因为它非常令人沮丧!

If anybody can shed any light on this situation, I would be very grateful as it is extremely frustrating!

谢谢

马特

推荐答案

也许视频视图消失后的动画会导致状态栏动画出现计时问题.

Maybe the animation from when the video view disappears is causing a timing issue with the status bar animation.

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

try delaying the statusBarHidden = NO call by a few seconds.

NSInteger delay = 3;

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
[UIApplication sharedApplication].statusBarHidden = NO;
});

这篇关于关闭MPMoviePlayerController后,顶部的状态栏消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆