长按事件按钮 [英] Long press event on button

查看:59
本文介绍了长按事件按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何使用uiview和uibutton?
UIButton长按事件

Possible Duplicate:
How to detect tap on Uitableview cell with uiview and uibutton?
UIButton Long Press Event

我正在通过表格自定义单元格加载按钮.如何确定用户单击按钮还是长按事件在按钮上?

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");
    }
}

这篇关于长按事件按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆