给button添加长按手势并侦测到此button


1, 添加手势

 

 self.longPressRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongPress:)];
[btn addGestureRecognizer:self.longPressRecognizer];

 

2,得到当前执行长点选的button

- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer

    UIButton *btn = (UIButton *)recognizer.view;

posted @ 2014-06-30 10:45  如来藏  阅读(368)  评论(0编辑  收藏  举报