1. 程式人生 > >iOS中如何通過點選UITableViewCell中的Button來獲取當前Cell的indexPath

iOS中如何通過點選UITableViewCell中的Button來獲取當前Cell的indexPath

- (void) btnOnClickTouched:(UIButton *)aButton { myTableViewCell* myCell = (myTableViewCell *)[aButton superView]; //表示Button新增在了Cell中。 //如果將Button新增在myCell.contentView 中, //myCell = (myTableViewCell *)[[aButton superView] superView]; indexPath cellPath = [self.tableView indexPathForCell:myCell];   NSIntage i = cellPath.row; //這個就是cell的indexPath.row;
}