我的iPhone應用程序有一個有趣的小問題。我有一張桌子和每個單元格的視圖,單擊時,全屏播放視頻,然後當您按下完成時,視頻停止並返回到表格視圖。唯一的問題是,當您在視頻加載的前2到3秒內按下完成時,當視圖返回到表格視圖時,屏幕頂部指示時間和電池電量等的欄不再存在那裏,它只是一個白色的空間。但是如果你在開始的幾秒鐘後按下完成,那麼當你回到桌子視圖時,一切都絕對好!我絕對不知道爲什麼發生這種情況,我在互聯網上發現的唯一的事情是這是一些傢伙幾乎完全一樣的問題,因爲我:關閉MPMoviePlayerController後頂部的消失狀態欄
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;
如果任何人都可以瞭解這種情況,我會非常感激,因爲這是非常令人沮喪的!
感謝,
馬特
謝謝,這是行得通的,但它似乎成功延遲的最短時間是1秒,這有點過長。如果它是我可以修復它的唯一方法,那麼它將會執行,但最好在視圖加載後立即顯示,而不是1秒後 –