我们就给cell一个代理方法
- // 点击按钮
- - (IBAction)click:(UIButton *)sender {
- if ([self.delegate respondsToSelector:@selector(MKJTableView:clickButton:)]) {
- [self.delegate MKJTableView:self clickButton:sender];
- }
- }
- // cell的代理方法
- - (void)MKJTableView:(MKJTableViewCell *)cell clickButton:(UIButton *)touchBtn
- {
- }
- // 这里的2和0可以根据需要求更改 这里就是第0段,第2行
- NSIndexPath * indexPath = [NSIndexPath indexPathForRow:2 inSection:0];
- UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath];
iOS 实现获取表格中点击的Cell
这篇博客介绍了如何在iOS应用中为表格视图(UITableView)的单元格(Cell)设置代理方法,以便在点击按钮时能够获取到当前或指定的Cell。通过实现点击事件的回调,可以获取到触发事件的indexPath,并使用tableView的cellForRowAtIndexPath方法来获取对应的 UITableViewCell。
2260

被折叠的 条评论
为什么被折叠?



