【发布时间】:2013-05-10 09:33:25
【问题描述】:
所以我想要我的 tableView 单元格中的三个按钮。我已经制作了一个自定义单元格,因此我自定义了自定义单元格中的按钮一次,而不是在cellForRowAtIndexPath 中一次又一次地进行操作
但我想为我正在使用的所有三个按钮添加一个选择器
[cell.btn1 addTarget:self action:@selector(firstAction:) forControlEvents:UIControlEventTouchUpInside];
在cellForRowAtIndexPath 内。这是最好的方法吗?每次滚动我的单元格时,addTarget 不会被初始化和重新初始化吗?那不会是额外的超载吗?有没有我不知道的更好的方法?
编辑
这就是我如何确定按下的按钮属于哪个单元格
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.feedTableView];
NSIndexPath *indexPath = [self.feedTableView indexPathForRowAtPoint:buttonPosition];
【问题讨论】:
标签: uitableview io uibutton