Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在控件隐藏时仅捕获MPMoviePlayerController视图上的一次单击/点击?_Iphone_Ipad_Mpmovieplayercontroller_Uigesturerecognizer - Fatal编程技术网

Iphone 如何在控件隐藏时仅捕获MPMoviePlayerController视图上的一次单击/点击?

Iphone 如何在控件隐藏时仅捕获MPMoviePlayerController视图上的一次单击/点击?,iphone,ipad,mpmovieplayercontroller,uigesturerecognizer,Iphone,Ipad,Mpmovieplayercontroller,Uigesturerecognizer,以前。有人建议我可以使用UIgestureRecognitor来完成这项工作 我能够以这种方式使用手势识别器捕捉屏幕上的双击,但不能捕捉单次点击。我使用的代码如下: ///**********/// singleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClickOnMediaView:)]; singleTapGestureRecog

以前。有人建议我可以使用UIgestureRecognitor来完成这项工作

我能够以这种方式使用手势识别器捕捉屏幕上的双击,但不能捕捉单次点击。我使用的代码如下:

///**********///
singleTapGestureRecognizer =
    [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClickOnMediaView:)];
singleTapGestureRecognizer.numberOfTapsRequired = 1;
[self.moviePlayer.view addGestureRecognizer:singleTapGestureRecognizer];
[singleTapGestureRecognizer release];
///**********///

为什么我无法使用此代码捕获MPMoviePlayerController视图上的单个点击?它处理单次点击有什么特别之处吗?

我知道这是一个有点老的问题,但如果有人需要,这里有一个解决方案。 要在同一视图上处理单点击和双点击,单点击识别器必须等待双点击识别器失败。大概是这样的:

UITapGestureRecognizer* doubleTapRecon = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap)];
[doubleTapRecon setNumberOfTapsRequired:2];
[doubleTapRecon setDelegate:self];
[self.view addGestureRecognizer:doubleTapRecon];

UITapGestureRecognizer* singleTapRecon = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap)];
[singleTapRecon setNumberOfTapsRequired:1];
[singleTapRecon requireGestureRecognizerToFail:doubleTapRecon];
[singleTapRecon setDelegate:self];
[self.view addGestureRecognizer:singleTapRecon];

请注意,如果您不使用ARC,则必须注意内存管理。

否以上答案不适用于获得单点击手势,您必须实现“UIAPTgestureRecognitizerDelegate”并使用该方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

因为“moviePlayer”也使用点击手势,所以要开始使用我们的自定义单次点击只需要上述方法。

可能是@Brad的愚弄,但这真的是同一个问题吗?这看起来像是我的后续行动。@Michael-我相信,在回顾了最初的问题之后,这是在问基本相同的问题。这也可能是这里描述的一个案例:,第一个问题中给出的答案对于他们试图做的事情来说是不可接受的。我会看看我是否能把它编辑成一个不同的问题。@Michael-好的,我想我的措辞使它变得清晰,与原来的问题分开了。我错了,这里有一个新问题。