【发布时间】:2011-05-13 21:26:45
【问题描述】:
我已使用 Apple 的“附件”示例代码在我的表格中添加自定义附件图像。该表正确呈现图像和所有内容,但是当我单击应该将我带到 accessoryButtonTappedForRowWithIndexPath 方法的图像时,没有任何反应,因为 indexPath 由于某种原因为零。请参阅此检查 indexPath 的方法:
- (void)accessoryButtonTapped:(id)sender event:(id)event
{
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
if (indexPath != nil)
{
[self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath];
}
}
【问题讨论】:
标签: cocoa-touch ios nsindexpath accessoryview