UITapGestureRecognizer选择器,sender是手势,而不是ui对象 [英] UITapGestureRecognizer selector, sender is the gesture, not the ui object

查看:157
本文介绍了UITapGestureRecognizer选择器,sender是手势,而不是ui对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列使用标签识别的图像视图。我为图像添加了一个轻击手势。

I have a series of imageviews that I identify using their tag. I have added a single tap gesture to the images.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImage:)];
[tableGridImage addGestureRecognizer:singleTap];
tableGridImage.userInteractionEnabled = YES;
[singleTap release];

这设法调用selectImage选择器ok,但将手势作为发送者传递。我需要imageview作为发件人,所以我可以得到标签。

This manages to call the selectImage selector ok, but passes the gesture as the sender. I need the imageview as the sender so I can get the tag.

关于如何获取imageview及其标签的任何想法?

Any ideas on how I can get the imageview and it's tag?

推荐答案

我想出了如何获取标签,这对我来说是问题中最重要的部分。由于手势是发件人,我发现它所附带的视图随之发送:

I figured out how to get the tag, which was the most important part of the question for me. Since the gesture is the sender, I figured out the the view it is attached to is sent along with it:

[(UIGestureRecognizer *)sender view].tag

如果有人能告诉我如何发送参数,我仍然很好奇通过UITapGestureRecognizer选择器。

I am still curious if anyone can tell me how to send an argument through a UITapGestureRecognizer selector.

这篇关于UITapGestureRecognizer选择器,sender是手势,而不是ui对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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