0

嗯..我有一个简单的动画,可以左右滑动 2 个图像视图.. 完成后,我想播放视频,但使用我现有的代码(如下),动画永远不会发生,视频开始播放。我该如何解决这个问题?谢谢..

NSString *movpath = [[NSBundle mainBundle] pathForResource:@"testvideo" ofType:@"m4v"];
    mpviewController = [[MPMoviePlayerViewController alloc]
                        initWithContentURL:[NSURL fileURLWithPath:movpath]];
    [mainView addSubview:mpviewController.view];



    [UIView animateWithDuration:0.5 animations:^{
        leftView.frame = CGRectOffset(leftView.frame, 160, 0);
        rightView.frame = CGRectOffset(rightView.frame, -160, 0);
    }completion:(void (^)(BOOL)) ^{

        MPMoviePlayerController *mp = [mpviewController moviePlayer];

        [mp prepareToPlay];
        [mp setFullscreen:YES animated:YES];
        mp.controlStyle = MPMovieControlStyleNone;

        [[mpviewController moviePlayer] play];

    }
     ];
4

1 回答 1

0

您的动画完成块看起来不对。试试这个:

 [UIView animateWithDuration:0.5 animations:^{
        leftView.frame = CGRectOffset(leftView.frame, 160, 0);
        rightView.frame = CGRectOffset(rightView.frame, -160, 0);
    } completion:^(BOOL finished){

        MPMoviePlayerController *mp = [mpviewController moviePlayer];

        [mp prepareToPlay];
        [mp setFullscreen:YES animated:YES];
        mp.controlStyle = MPMovieControlStyleNone;

        [[mpviewController moviePlayer] play];

    }];
于 2012-09-13T00:57:43.293 回答