在UIImageView上检测UITableViewCell id [英] detect UITableViewCell id on UIImageView

查看:52
本文介绍了在UIImageView上检测UITableViewCell id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView. 我将UIImageView放在每行UITableViewCell上. 我使用下面的代码来检测UIImageViews上的触摸

I have a UITableView. I place an UIImageView on each row UITableViewCell. I used the codes below to detect the touch on the UIImageViews

-(void) touchBegan:(NSSet*) touches withEven:(UIEvent*)event
{
CGPoint pt=[[touches anyObject] locationInView:self];


}

看来我只能得到pt, 是否有可能检测到触摸了哪一行的UIImageView?

It looks like I can only get the pt, Is it possbile to detect which row's UIImageView is touched?

谢谢

interdev

推荐答案

是的,这是可能的(UITableView具有允许特定行属于哪个行的方法):

Yes, it is possible (UITableView has a method allowing to what row specific point belongs to):

-(void) touchBegan:(NSSet*) touches withEven:(UIEvent*)event
{
   CGPoint pt=[[touches anyObject] locationInView:self];
   CGPoint pointInTable = [[touches anyObject] locationInView:yourTableView];
   NSIndexPath* path = [yourTableView indexPathForRowAtPoint:pointInTable];
}

这篇关于在UIImageView上检测UITableViewCell id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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