Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone:将UIImage添加到UIImageView会添加第二个图像_Iphone_Uiimageview_Uiimage - Fatal编程技术网

iPhone:将UIImage添加到UIImageView会添加第二个图像

iPhone:将UIImage添加到UIImageView会添加第二个图像,iphone,uiimageview,uiimage,Iphone,Uiimageview,Uiimage,我有一个UIImageView,我已经设置了一个映像。这很好,但稍后,我想更改该图像。因此,我为image属性设置了一个新图像,但当我查看应用程序时,该图像被设置为第一个图像之上的第二个图像: UIImageView *image; image = (UIImageView *)[cell viewWithTag:0]; image.image = [UIImage imageNamed:@"History_Row2.png"]; 如何替换UIImageView中的当前图像,而不是添加另一个图

我有一个UIImageView,我已经设置了一个映像。这很好,但稍后,我想更改该图像。因此,我为image属性设置了一个新图像,但当我查看应用程序时,该图像被设置为第一个图像之上的第二个图像:

UIImageView *image;
image = (UIImageView *)[cell viewWithTag:0];
image.image = [UIImage imageNamed:@"History_Row2.png"];

如何替换UIImageView中的当前图像,而不是添加另一个图像

我是通过保留UIImageView,并保留一个作为ivar的引用,在dealloc上发布来实现的

image = (UIImageView *)[cell viewWithTag:0];

返回的是UITableViewCell而不是UIImageView,这是因为标记0是默认值,需要将其更改为其他数字。这样做之后,它起了作用。

我不知道为什么这样做会与您现在所做的有所不同,但这正是我为了让它起作用所做的。