如何检测生成事件的对象

如何检测生成事件的对象

本文介绍了在UILongPressGestureRecognizer上,如何检测生成事件的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个UIButton的视图。我已成功使用UILongPressGestureRecognizer实现以下作为选择器;

I have a view with several UIButtons. I have successfully implemented using UILongPressGestureRecognizer with the following as the selector;

- (void)longPress:(UILongPressGestureRecognizer*)gesture {
    if ( gesture.state == UIGestureRecognizerStateEnded ) {
        NSLog(@"Long Press");
    }
}

我在这个方法中需要知道的是哪个UIButton因为我需要做一些不同的东西,这取决于收到长按的按钮。

What I need to know within this method is which UIButton received the longpress since I need to do something different, depending on which button received the longpress.

希望答案不是映射长按发生位置的坐标的问题到按钮的边界 - 宁愿不去那里。

Hopefully the answer is not some issue of mapping the coordinates of where the longpress occured to the bounds of the buttons - would rather not go there.

有什么建议吗?

谢谢!

推荐答案

这可以在 gesture.view 中找到。

这篇关于在UILongPressGestureRecognizer上,如何检测生成事件的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 14:16