1

スクリーンショットはこちら: http://i.stack.imgur.com/fru4x.png

そのため、MPMoviePlayer オブジェクトを含む UIViewController をプッシュする UITableViewController があります。私が発見したのは、MPMoviePlayer をサブビューとして読み込むと、ステータスバーが作成されるということです。このステータスバーはナビゲーションバーを上部に押し下げ、空白を引き起こします。私はstackoverflowでさまざまなトピックを見てきましたが、何もうまくいかないようです:

iPhone: UINavigationController の上部にある奇妙なスペース

なぜ UIView が約 10px ずつ押し上げられているのかわかりません

フルスクリーン モードから MPMoviewPlayer を閉じた後、UITableView の下の空 (白い) 行

MPMoviePlayerController から StatusBar を非表示にする

UIViewController は、次のコード (PresetViewController.m) でプッシュされています。

-(void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = [indexPath row];
    //PresetNode *tempNode = [appDelegate.presetData objectAtIndex:row];

   ..... SOME DATA IS LOADED HERE

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
    MoviePlayer *player = [[MoviePlayer alloc] initWithNibName:nil bundle:nil andVideoArray: presetVideoURLs];
    [self.navigationController pushViewController:player animated:NO];
    [player playVideoAtIndex:0];
    [player release];

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

View Controller が読み込まれると、MoviePlayer.m で次のコードを使用しているにもかかわらず、何らかの理由でビューの上部にあるステータスバーに読み込まれます。

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

ムービーをランドスケープ モードに設定して再生します。次に、完了ボタンが押されたかどうかを確認します。完了ボタンが押されたら、ビューをポップします。何らかの理由で、ビューがポップされると、その背後にある uitableviewcontroller が数ピクセル押し下げられます。ムービープレーヤーが作成したステータスバーは、すべてを押し下げます。ムービープレーヤーのコード (MoviePlayer.m) は次のとおりです。

-(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];
}
}
4

1 に答える 1

1

viewController.viewのフレーム(viewController.view.frame)を画面全体を占めるCGRectに設定してみてください。

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

サイズを手動で設定すると、空白がなくなります。

于 2011-06-06T02:52:34.573 に答える