UITapGestureRecognizer有几个视图

时间:2012-01-08 16:44:46

标签: iphone objective-c

我正在使用:

       UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleViewClicked:)];
       [tmp addGestureRecognizer:gestureRecognizer];
       [gestureRecognizer release];

在我点击的视图(我的示例为bigview)时获取通知(我有很多视图),并且在前面有一个UIView(一个空白的)他在前面视图(这个视图在视图之前位于前面是有原因的。)

由于tmp位于前面,因此在点击bigview时收到通知现在存在问题。

有这样的解决方案吗?

修改


bigview我有UISwipeGestureRecognizer

UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeRight:)];
        [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
        [itemsView addGestureRecognizer:recognizer];
        [recognizer release];

如果我将bigview中的userInteractionEnabled设为NO,则他不会收到关于滑动的通知

1 个答案:

答案 0 :(得分:0)

两个选项:

一个。在该大/空视图上将userInteractionEnabled设置为NO。

B中。在该大/空白视图上实施pointInside:withEvent:

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event 
{
    // UIView will be "transparent" for touch events if we return NO
    return NO;
}

(取自allowing-interaction-with-a-uiview-under-another-uiview