处理事件的方法,代码:

<span class="lnum" style="color: rgb(96, 96, 96);">   1:  </span><span class="rem" style="color: rgb(0, 128, 0);">//处理单指事件</span>
   2:  - (void)handleSingleFingerEvent:(UITapGestureRecognizer *)sender
<span class="lnum" style="color: rgb(96, 96, 96);">   3:  </span>{
   4:      if (sender.numberOfTapsRequired == 1) {
<span class="lnum" style="color: rgb(96, 96, 96);">   5:  </span>        <span class="rem" style="color: rgb(0, 128, 0);">//单指单击</span>
   6:          NSLog(@"单指单击");
<span class="lnum" style="color: rgb(96, 96, 96);">   7:  </span>    }<span class="kwrd" style="color: rgb(0, 0, 255);">else</span> <span class="kwrd" style="color: rgb(0, 0, 255);">if</span>(sender.numberOfTapsRequired == 2){
   8:          //单指双击
<span class="lnum" style="color: rgb(96, 96, 96);">   9:  </span>        NSLog(<span class="str" style="color: rgb(0, 96, 128);">@"单指双击"</span>);
  10:      }
<span class="lnum" style="color: rgb(96, 96, 96);">  11:  </span>}
  12:  //处理双指事件
<span class="lnum" style="color: rgb(96, 96, 96);">  13:  </span>- (<span class="kwrd" style="color: rgb(0, 0, 255);">void</span>)handleDoubleFingerEvent:(UITapGestureRecognizer *)sender
  14:  {
<span class="lnum" style="color: rgb(96, 96, 96);">  15:  </span>    <span class="kwrd" style="color: rgb(0, 0, 255);">if</span> (sender.numberOfTapsRequired == 1) {
  16:          //双指单击
<span class="lnum" style="color: rgb(96, 96, 96);">  17:  </span>        NSLog(<span class="str" style="color: rgb(0, 96, 128);">@"双指单击"</span>);
  18:      }else if(sender.numberOfTapsRequired == 2){
<span class="lnum" style="color: rgb(96, 96, 96);">  19:  </span>        <span class="rem" style="color: rgb(0, 128, 0);">//双指双击</span>
  20:          NSLog(@"双指双击");
<span class="lnum" style="color: rgb(96, 96, 96);">  21:  </span>    }
  22:  }

将相应代码复制到你的工程中即可使用,由于代码中已经有详细的解释说明,这里就不在重复解释了。

代码中只是列举了单指与双指对于单击或多击的处理,同理多指的操作需修改numberOfTouchesRequired属性,对点击的次数需修改numberOfTapsRequired属性。

对于其他手势例如UISwipeGestureRecognizerUILongPressGestureRecognizer,UILongPressGestureRecognizer的操作使用类似处理。