Iphone MPMoviePlayer在导航栏上方留下空间

Iphone MPMoviePlayer在导航栏上方留下空间,iphone,xcode,mpmovieplayer,Iphone,Xcode,Mpmovieplayer,屏幕截图如下: 所以我有一个UITableViewController推送一个UIViewController,其中有一个MPMoviePlayer对象。我发现,当我将MPMoviePlayer作为子视图加载时,它会创建一个状态栏。此状态栏向下推导航栏a至顶部,导致出现空白。我看了一堆关于stackoverflow的不同主题,但似乎没有任何效果: 正在使用以下代码(PresetViewController.m)推送UIViewController: 当视图控制器加载时,出于某种原因,它会

屏幕截图如下:

所以我有一个UITableViewController推送一个UIViewController,其中有一个MPMoviePlayer对象。我发现,当我将MPMoviePlayer作为子视图加载时,它会创建一个状态栏。此状态栏向下推导航栏a至顶部,导致出现空白。我看了一堆关于stackoverflow的不同主题,但似乎没有任何效果:

正在使用以下代码(PresetViewController.m)推送UIViewController:

当视图控制器加载时,出于某种原因,它会加载到视图顶部的状态栏中,即使我在MoviePlayer.m中使用了以下代码:

- (void)viewDidAppear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[super viewDidAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
-(void) playVideoAtIndex: (NSInteger)index{

NSString *rootPath = [[NSBundle mainBundle] resourcePath];
NSString *filePath = [rootPath stringByAppendingPathComponent: [self.movieArray objectAtIndex:index]];
NSURL *fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
self.yourMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: fileURL];

[yourMoviePlayer setControlStyle:MPMovieControlStyleFullscreen];



[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:YES];

[[self navigationController] setNavigationBarHidden: YES];

yourMoviePlayer.scalingMode = MPMovieScalingModeFill;
[[yourMoviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI/2)];
self.yourMoviePlayer.view.frame = self.view.frame;

[yourMoviePlayer setFullscreen:YES animated:NO];

[[NSNotificationCenter defaultCenter] 
 addObserver:self
 selector:@selector(checkForNextMovie:)                                                 
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:yourMoviePlayer];

[[self view]addSubview:yourMoviePlayer.view];
//[[self navigationController] presentMoviePlayerViewControllerAnimated:self];
//---play movie---
[yourMoviePlayer play];    

}

-(void) checkForNextMovie:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter] 
 removeObserver:self
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];

NSNumber *reason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

[yourMoviePlayer release];
if((currentIndex+1) == [self.movieArray count] || [reason intValue] == MPMovieFinishReasonUserExited){
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
    [player.view removeFromSuperview];
    [[self navigationController] setNavigationBarHidden: NO];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    //self.wantsFullScreenLayout = YES;

    [[self navigationController] popViewControllerAnimated:NO];
    if ([UIApplication sharedApplication].statusBarOrientation != self.interfaceOrientation) {
        [[UIApplication sharedApplication] setStatusBarOrientation:self.interfaceOrientation animated:NO];
    }
}
else{
    currentIndex++;
    [self playVideoAtIndex: currentIndex];
}
}
我将电影设置为横向模式并播放。然后我检查是否按下了“完成”按钮。如果按下“完成”按钮,我将弹出视图。出于某种原因,当视图弹出时,它后面的uitableviewcontroller会向下推几个像素。电影播放器创建的状态栏将所有内容向下推。以下是影音播放器代码(movieplayer.m):


尝试将viewController.view的帧(viewController.view.frame)设置为占据整个屏幕的CGRect:

viewController.view.frame = CGRectMake( 0, 0, 320, 480);

手动设置大小应消除空白。

尝试将viewController.view的框架(viewController.view.frame)设置为占据整个屏幕的CGRect:

viewController.view.frame = CGRectMake( 0, 0, 320, 480);

手动设置大小应该可以消除空白。

我最终使用仿射变换将UINavigationBar向上移动了20像素。谢谢你的帮助!最后,我使用仿射变换将UINavigationBar向上移动了20像素。谢谢你的帮助!