如何使 MPMoviePlayer 在点击后显示控件



这是我的代码,它不能在点击上工作。这就是我如何看待我的代码:播放器的控制样式最初是隐藏的。玩家视图中有一个点击手势识别器。当它点击时,我想显示控件出现:

- (void)viewDidLoad {
    _player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    [_player.view setFrame:CGRectMake(0, 0, 540, 250)];
     [self.view addSubview:_player.view];
    _player.view.center = self.view.center;
    //Control style is None
    _player.controlStyle = 0;
    //Gesture
     tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    [_player.view addGestureRecognizer:tap];
    tap.numberOfTapsRequired = 1;
    _player.scalingMode = 2;
    [_player prepareToPlay];
    [_player shouldAutoplay];
}
- (void)handleTap:(UITapGestureRecognizer *)gesture {
    // ControlStyle changed to ShowEmbedded
        _player.controlStyle = 1;
}

我已经在玩家区域的视图中添加了点击识别器,它应该显示,但遗憾的是它没有。我已经在我的实际代码中添加了超级视图DidLoad。这不是问题所在。

制作一个按钮。点击按钮时,视频应暂停。然后更改其中的控件样式。然后,用户必须单击 才能看到控件。

- (IBAction)showControls:(id)sender {
    [_player pause];
    _player.controlStyle =  MPMovieControlStyleEmbedded;   
}

最新更新