iOS SDK 提供了 UITapGestureRecognizer 点击手势,我们可以通过它实现打击、双击以及多点击事件,默认情况下单击事件,通过设置 numberOfTapsRequired 属性,可以决定需要连续点击几次触发tap事件,以下代码实现为 double tap:
UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
tap.numberOfTapsRequired = 2;
[self.headerView addGestureRecognizer:tap];
也就是说 tap.numberOfTapsRequired = n;
n为多少时,点击了n次才会触发tap事件。