2010-03-03 93 views
1

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { touchStartTime = [event timestamp]; }是否有可能在UITableViewCell上有“touchesBegan”?

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 
    NSTimeInterval touchTimeDuration = [event timestamp] - touchStartTime; 
} 

touchStartTime在类级定义的。

任何想法为什么这不会识别触摸事件?

感谢您的帮助!

+0

是否启用了多点触控? – willcodejavaforfood 2010-03-03 15:54:55

+0

Unfortunetely所以:( – 2010-03-03 17:18:20

回答

-1

就我个人而言,根据我对UITableView的经验,我不认为你可以使用触摸事件。

您可能需要研究其他解决方法。例如,尝试使用选择作为帮手?

0

是的,这是可以做到的。我使用自定义的UITableViewCell子类设置了一个测试项目,并使用与您具有相同的方式定义了方法,向touchesEnded添加了一个日志以打印touchTimeDuration。我在模拟器中运行它,它似乎为我工作。

您如何确定您的代码是否识别事件?

+0

嘿麦克,欢呼的答复。 的代码工作正常,在XIB文件的底层(即UIImageView的)。 我可以触摸并按住,当我抬起我的手指断UIImageView的NSLog指出了我手指在屏幕上的时间,但不会在UITableViewCell(这是一个自定义的单元格,如果这有什么区别)上初始化的。 – 2010-03-04 10:06:11