ini*_*nch 0 iphone objective-c uitableview
我想在每个UITableViewCell中都有一个UIButton,它允许我在对应于该行的对象上执行选择器.他们使用它的方法是为每一行创建一个单独的UITableViewCell(不重用),添加一个用该行标记的新UIButton.当按钮被轻击时,生成的选择器检查发送者的标签以确定要更改的对象.
有没有更好的方法呢?首先,我不会重复使用不幸的细胞,使用UIView.tag似乎非常hacky.
小智 6
您可以在所有UIButton上使用相同的标签号.
要提取已单击的行号,请在选择器中实现此代码:
- (void)buttonClicked:(id)sender
{
UITableViewCell * clickedCell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath * clickedButtonPath = [self.tableView indexPathForCell:clickedCell];
int rownumber = clickedButtonPath.row;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
583 次 |
| 最近记录: |