iOSはどのtableViewセルのButtonボタンをクリックしたかをどのように取得しますか?


1.まずcell上のbuttonボタンのクリック方法をcell展示に書き込む
//cell 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PraiseListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PraiseListCell" forIndexPath:indexPath];
    // 
    [cell.attentionClickButton addTarget:self action:@selector(onTouchBtnInCell:) forControlEvents:(UIControlEventTouchUpInside)];
    return cell;
}

2.buttonボタンのクリック方法で実現
- (void)onTouchBtnInCell:(UIButton *)sender {
    CGPoint point = sender.center;
    point = [self.tableView convertPoint:point fromView:sender.superview];
    NSIndexPath* indexpath = [self.tableView indexPathForRowAtPoint:point];
    NSLog(@"%ld",(long)indexpath.row);
}

3.クリックしたindexpathを手に入れることで、データや配列を操作したり、自分の欲しいものを作ったりすることができます