防止在UITextView上点击事件

时间:2012-02-21 13:21:32

标签: iphone objective-c events uitextview uigesturerecognizer

  

2012-02-21 11:59:18.106 textView [20977:fe03]; target =<(action = delayed:,target =)>>

     

2012-02-21 11:59:18.107 textView [20977:fe03]; target =<(action = handlePan:,target =)>>

     

2012-02-21 11:59:18.108 textView [20977:fe03]; target =<(action = oneFingerTripleTap:,target =)&gt ;; numberOfTapsRequired = 3>

     

2012-02-21 11:59:18.108 textView [20977:fe03]; target =<(action = oneFingerDoubleTap:,target =)&gt ;; numberOfTapsRequired = 2>

     

2012-02-21 11:59:18.109 textView [20977:fe03]; target =<(action = twoFingerSingleTap:,target =)&gt ;; numberOfTouchesRequired = 2>

     

2012-02-21 11:59:18.123 textView [20977:fe03]; target =<(action = tapAndAHalf:,target =)>>

     

2012-02-21 11:59:18.124 textView [20977:fe03]; target =<(action = twoFingerRangedSelectGesture:,target =)>>

     

2012-02-21 11:59:18.124 textView [20977:fe03]; target =<(action = oneFingerTap:,target =)>>

     

2012-02-21 11:59:18.129 textView [20977:fe03]; target =<(action = loupeGesture:,target =)>>

在UITextView上的gestureRecogniser列表上方。我需要在UITextView上阻止事件:twoFingerSingleTap,但只有这个事件。有可能吗?

2 个答案:

答案 0 :(得分:4)

UITextView,与UIView的任何其他子类一样,具有gestureRecognizers属性,其中包含附加到视图的所有手势识别器的NSArray。枚举此数组,找到您正在寻找的识别器并禁用它。

答案 1 :(得分:3)

您需要以下内容:

for (UIGestureRecognizer *g in myTextView.gestureRecognizers)
{
    if ([g isKindOfClass:[UITapGestureRecognizer class]])
    {
        if (([(UITapGestureRecognizer *)g numberOfTouchesRequired] == 2) && ([(UITapGestureRecognizer *)g numberOfTapsRequired] == 1))
        {
            [g setEnabled: NO];
        }
    }
}