1
我有一個視圖控制器,其中包括一個MPMoviePlayer裏面。我隱藏了導航欄,並希望在視頻暫停時顯示它。MPMoviePlayerController iPhone導航欄問題
當視頻加載時,它工作得很好。在我暫停後,視頻導航欄出現,但它將整個播放器視圖稍微向下。如何讓導航欄出現而不影響播放器視圖。
這裏是我使用的代碼:
在viewDidLoad中():
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(videoPlayerPlaybackStateChanged:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
[self setWantsFullScreenLayout:YES];
[moviePlayer prepareToPlay];
//For viewing partially.....
moviePlayer.view.backgroundColor = [UIColor blackColor];
//[moviePlayer.view setFrame:CGRectMake(0, 0, 320, 410)];
[moviePlayer.view setFrame:[self.view bounds]];
moviePlayer.fullscreen = YES;
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[self.view addSubview:moviePlayer.view];
[moviePlayer play];
- (void) videoPlayerPlaybackStateChanged:(NSNotification*) aNotification
{
MPMoviePlayerController *player = [aNotification object];
if(player.playbackState == MPMoviePlaybackStatePaused){
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBarHidden = NO;
}
else if(player.playbackState == MPMoviePlaybackStatePlaying){
self.navigationController.navigationBarHidden = YES;
}
[player autorelease];
}
預先感謝您...
謝謝你的作品就像一個魅力.. – gurkan 2011-02-15 11:51:50