gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 03:28:25 26 4
gpt4 key购买 nike

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

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;

如果有人能阐明这种情况,我将不胜感激,因为这非常令人沮丧!

谢谢,

马特

最佳答案

也许视频 View 消失时的动画导致状态栏动画出现时间问题。

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

NSInteger delay = 3;

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

关于objective-c - MPMoviePlayerController 关闭后顶部状态栏消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7176211/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com