UITapGestureRecognizer是没有tag属性,但他有UIView的属性,我们可以通过给UIView添加tag属性,从而标记UITapGestureRecognizer。
UIView *itemView = [[UIView alloc ] init];
itemView.userInteractionEnabled = YES;
itemView.tag = 1;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(itemTapClick:)];
[tap setNumberOfTapsRequired:1];
[itemView addGestureRecognizer:tap];
- (void)itemTapClick:(UITapGestureRecognizer *)sender
{
UIView *view = sender.view;
SaintiLog(@"%ld",(long)view.tag);
}