Set tag
value to each button
in TableViewCell
and add target
also as shown below..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
cell.btn.tag = indexPath.row;
[btn addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
Now add a selector method btnTapped
like shown below. This method calls every time for each button click event in tableview cell.
- (void)btnTapped:(UIButton *)sender {
UITableViewCell * cell = [[sender superview] superview];
NSIndexPath * path = [self.tableView indexPathForCell:cell];
}
Here you have indexpath
of the selected button, customise however you want.