0
我有UITableViewCells每个与几个UIImageViews。我想将事件传递给父UITableViewController,以便它可以对其执行操作。我怎样才能发回信息给UITableViewController让它知道哪个UIImageView触发了这个事件。使用下面的代码,看起来UITableViewController touchesEnded在任何子UITableViewCells触发事件时触发。任何方式在UIEvent中传递信息?如何识别哪个事件通过nextResponder传递给父项?
有没有更好的方法去处理事件?
//UITableViewCell
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([touch view] == imageView)
{
[[self nextResponder] touchesEnded:touches withEvent:event];
}
}
//UITableViewController
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
NSLog(@"clicked");
}
谢谢,我也能够通过使用代表实现目标。我建立了一个委托协议,并且工作得很好(还在发送者对象中存储了标识符数据)。 – Ryan 2012-03-06 22:28:04