简体   繁体   English

以编程方式添加的UIButton即使在更改或删除图像后仍保留背景图像

[英]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. 但是问题是,当我将图像1.png更改为其他图像(我再次将其命名为1.png)时,即使从项目中删除该图像,它也会显示相同的图像。 I am using ARC... here part of my code: 我正在使用ARC ...这是我的部分代码:

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];

Try to clean and rebuild the project. 尝试清理并重建项目。 Also delete the app from device/simulator before running it again. 在再次运行之前,还要从设备/模拟器中删除该应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM