从UITableViewCell中的多个附件按钮确定发件人?
问题描述:
现在我有一个包含2个附件按键的自定义的UITableViewCell一个UITableView。从UITableViewCell中的多个附件按钮确定发件人?
当按钮中的一个被轻敲它触发任一:
(void) shareButtonTapped:(UIControl *)button withEvent:(UIEvent *) event
{
NSIndexPath * indexPath = [self.tableview indexPathForRowAtPoint:[[[event touchesForView: button] anyObject] locationInView: self.tableview]];
if (indexPath == nil)
return;
[self.tableview.delegate tableView:self.tableview accessoryButtonTappedForRowWithIndexPath:indexPath];
}
或
(IBAction)callButtonTapped:(UIControl *)button withEvent:(UIEvent *)event {
NSIndexPath * indexPath = [self.tableview indexPathForRowAtPoint:[[[event touchesForView: button] anyObject] locationInView: self.tableview]];
if (indexPath == nil)
return;
[self.tableview.delegate tableView:self.tableview accessoryButtonTappedForRowWithIndexPath:indexPath];
}
我然后使用下面的方法来处理触摸事件。
(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Accessory tapped for row %d", indexPath.row);
}
我的问题:在“accessoryButtonTappedForRowWithIndexPath”我怎么能找出其中两个按钮的被压在的UITableViewCell?我想要以不同的方式处理每个触摸。
答
由于玛丽亚姆指出,我用我自己的自定义的方法来接听电话,而不是内置的accessoryBUttonTappedForRowWithIndexPath方法。
为什么你最终会调用* accessoryButtonTappedForRowWithIndexPath *,为什么不叫你的一个自定义的方法? –
我认为这是最佳实践...假设按钮应该如何在UITableViewCells中处理。我在这里不正确吗?我需要按下以及按钮的索引键的类型按 – Rohan
据我所知,因为你没有使用辅助按钮,这个方法并不需要被调用。您可以实现自己的事件处理程序方法。 –