在我的項目中,我使用嵌入式視圖,其中包含MPMoviePlayerController。MPMoviePlayerController在全屏模式下停止工作//縱向定向// iOS 7
此電影播放器在點擊全屏切換後停止工作 - 它在全屏模式下再播放1秒,然後停止並返回到嵌入模式。
它只發生在縱向模式下,僅適用於iOS 7 - 如果我在橫向模式下切換全屏模式,然後旋轉設備,它會正常工作。
我找到了原因 - 不知何故導航欄參與。我在項目中使用ECSlidingViewController並設置導航欄半透明「NO」初始化過程中:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myViewController];
navController.navigationBar.translucent = NO;
self.topViewController = navController;
如果我設置了navController.navigationBar.translucent = YES;
電影播放器工作正常。但我必須有半透明=否。
所以我試圖玩電影播放器事件MPMoviePlayerWillEnterFullscreenNotification和MPMoviePlayerWillExitFullscreenNotification。 有趣的是,如果我在進入全屏模式之前讓navBar半透明或隱藏它,視頻播放時間會更長一些(大約3-4秒),但行爲是相同的。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerWillEnterFullScreen:)
name:MPMoviePlayerWillEnterFullscreenNotification
object:nil];
-(void)moviePlayerWillEnterFullScreen:(id)sender{
[self.navigationController setNavigationBarHidden:YES animated:NO];
OR
self.navigationController.navigationBar.translucent = YES;
}
任何想法我可以用這個做的是大加讚賞。
UPD。 這個bug在iOS 7.0.4中沒有了
聽起來好像有某種類別的(僞重寫)掛羊頭賣狗肉導航欄繼續。如果是這種情況,確保每次使用播放器時禁用它,因爲它的接口實際上依賴於UINavigationBar作爲上部。如果不禁用,那個類別上的類別以及swizzles在後面都會留下混亂。 – Till
謝謝@Till我檢查了項目 - 沒有類別或其他navBar定製。 –
那還包括'UINavigationBar'的'drawRect:'代碼,是否正確? – Till