Search code examples
iphoneiosuiscrollviewuibutton

Programmatically added UIButtons keep the background image even after the image is changed or deleted


I have an array of programmatically added buttons in slide-view. Everything is configured and works fine after including my images they show up. But the problem is that when I change the image 1.png with some other (I named it 1.png again) it shows the same image even that it is deleted from my project. I am using ARC... here part of my code:

NSString *imagePath = [[NSString alloc] init];
imagePath = [NSString stringWithFormat:@"%d.png", i];
UIImage *buttonImage = [[UIImage alloc] init];
buttonImage = [UIImage imageNamed:imagePath];
[aButton setImage:buttonImage forState:UIControlStateNormal];

Solution

  • Try to clean and rebuild the project. Also delete the app from device/simulator before running it again.