UILongPressGestureRecognizer *longPressGR =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
longPressGR.allowableMovement=NO;
longPressGR.minimumPressDuration = 0.2;
[btn addGestureRecognizer:longPressGR];
[longPressGR release];
//响应的事件
-(IBAction)handleLongPress:(id)sender{
UIButton *button=(UIButton*)[(UILongPressGestureRecognizer *)sender view];
NSInteger ttag=[button tag];
}
iOS按钮长按
时间: 2024-10-08 23:18:54