检测TableCell中UIButton的IndexPath

时间:2014-10-14 19:03:20

标签: ios objective-c uibutton

我已将UIButton添加到连接到以下方法的原型单元格中。在UITableViewController上填充了几个原型单元格。但是,每当我运行它时,path.row始终为每个表格单元格返回0

- (IBAction)deleteButton:(UIButton *)sender {
    UIButton *button = (UIButton *)sender;
    UITableViewCell *cell = (UITableViewCell*)[button superview];
    NSIndexPath *path = [self.tableView indexPathForCell:cell];

    NSLog(@"You deleted %ld",(long)path.row);

}

0 个答案:

没有答案