本文介绍了长按事件按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过表格自定义单元格加载按钮.如何确定用户单击按钮还是长按事件在按钮上?
I am loading button through table custom cell.How do i identify whether user's single click or long press event on button?.
推荐答案
我只是用谷歌搜索,我从stack-overflow
i just google it and i got best answer from stack-overflow This
- (void)viewDidLoad
{
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[self.button addGestureRecognizer:longPress];
[longPress release];
[super viewDidLoad];
}
和事件:-
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
NSLog(@"Long Press");
}
}
这篇关于长按事件按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!