I agree with @wuii, but I think the answer can be clearer. The idea is that reused cells have their view hierarchy already built, so it's harmful to do it again each time a cell is reused (which is all of the time during scrolling). The advice can be encapsulated in a "lazy getter" that returns the cell's urgent button.
// above @implementation
#define kURGENT_BUTTON_TAG (256)
- (UIButton *)urgentButtonInCell:(UITableViewCell *)cell {
UIButton *urgentButton = (UIButton *)[cell viewWithTag:kURGENT_BUTTON_TAG];
if (!urgentButton) {
urgentButton = [[UIButton alloc]initWithFrame:CGRectMake(71, 27, 18, 18)];
urgentButton.tag = kURGENT_BUTTON_TAG;
[cell addSubview:urgentButton];
}
return urgentButton;
}
Now your configureCell can just ask for the button:
UIButton *urgentButton = [self urgentButtonInCell:cell];
UIImage *image = ([isUrgent isEqualToString:@"Urgent"])? [UIImage imageNamed:@"urgent-3"] : nil;
[urgentButton setImage:image forState:UIControlStateNormal];