2

我有 MPMoviePlayerController,它有一些 UIGestureRecognizers。它在正常视图中运行良好,但是当播放器进入全屏时,即使事件被绑定,它也不会触发事件。

这是我绑定事件的方式:

UISwipeGestureRecognizer * nextChannelRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoNextChannel)];
    [nextChannelRecognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [[player.view.subviews objectAtIndex:0] setUserInteractionEnabled:YES];
    [[player.view.subviews objectAtIndex:0] addGestureRecognizer:nextChannelRecognizer];

    UISwipeGestureRecognizer * previousChannelRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPreviousChannel)];
    [previousChannelRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [[player.view.subviews objectAtIndex:0] addGestureRecognizer:previousChannelRecognizer];

    for (UIGestureRecognizer *g in ((UIView *)[player.view.subviews objectAtIndex:0]).gestureRecognizers) {
        NSLog(@"g %@", g.class);
    }

在普通视图和全屏中,循环中的代码输出这些

MPTapGestureRecognizer
MPSwipeGestureRecognizer
UIPinchGestureRecognizer
MPActivityGestureRecognizer
UITapGestureRecognizer
UITapGestureRecognizer
UIPinchGestureRecognizer
UISwipeGestureRecognizer
UISwipeGestureRecognizer

我尝试添加另一个带有玩家视图视图边界的临时视图,并将相同的事件绑定到它,但结果是相同的。

你能告诉我为什么它不起作用吗?怎么了?

4

0 回答 0