Reputation: 226
I have a tableview and i have to use button in it.Based on tableViewCell i have to perform differnt action for different cell.How to distinguish which cell's button is clicked?
Upvotes: 1
Views: 379
Reputation: 6166
All you have to do is set a tag for the button in cellforrowatindex delegate fo UITableViewCell and then you will have to check the tag for the same in the action of the button.
if(((UIButton *)sender).tag==someIntValue)
{
//your statement
}
Upvotes: 2
Reputation: 32061
You can set the tag property of the UIButton to the cell's indexPath.row:
button.tag = indexPath.row
Then in your button selector method, you can do:
-(void)handleButtonClick:(id)sender
{
UIButton *button = (UIButton*)sender;
indexPathRow = button.tag;
}
Upvotes: 1