I have created a UIbutton inside a UITableView. I have multiple rows. On touching the button of a particular row I want the image of that particular button to change. The button I am adding is a checkbox. So every time I touch the button, its image will change.
Here is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
/*
Some code
*/
//Checkbox
UIImage *buttonImage = [UIImage imageNamed:@"arrow-not-checked.png"];
btnConfirm = [UIButton buttonWithType:UIButtonTypeCustom];
btnConfirm.tag =[[arrID objectAtIndex:indexPath.row] intValue];
[btnConfirm setImage:buttonImage forState:UIControlStateNormal];
btnConfirm.frame = CGRectMake(checkboxXX, 10.0, buttonImage.size.width, buttonImage.size.height);
[btnConfirm addTarget:self action:@selector(AddToCart:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btnConfirm];
}
-(void)AddToCart:(id)sender
{
UIButton *btnTemp=sender;
int iTag = btnTemp.tag;
// I want to change image of sender
}
Try this. Hope this helps.