UILongPressGestureRecognizer的回调中可以.view来获取控件
///创建长按手势
UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:sl];
///设置触发时间
longPress.minimumPressDuration=1;
///给btn添加手势
[btnaddGestureRecognizer:longPress];
//长按手势处理方法
- (void) longPress:(UILongPressGestureRecognizer *)gesture{
// gesture.minimumPressDuration=3;
if (gesture.state==UIGestureRecognizerStateBegan) {
NSLog(@"长按触发tag =%ld", gesture.view.tag);
}
}
////通过字符串创建SEL
NSString*str = @"longPress:";
SEL sl =NSSelectorFromString(str);
UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:sl];