Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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视图显示上一个图像未更新下一个图像_Iphone_Objective C - Fatal编程技术网

Iphone UIImage视图显示上一个图像未更新下一个图像

Iphone UIImage视图显示上一个图像未更新下一个图像,iphone,objective-c,Iphone,Objective C,UIImage视图显示上一个图像而不更新下一个图像。这是我的代码 [userImage setImageWithURL:[NSURL URLWithString:[Engin shared].imagePath] placeholderImage:[UIImage imageNamed:@"dummyImge.png"]]; 当我第一次出现在这个视图中时,我在我的viewdidload函数中添加了这个代码ok first time image update成功,之后我在服务器上更新了一个新的图

UIImage视图显示上一个图像而不更新下一个图像。这是我的代码

[userImage setImageWithURL:[NSURL URLWithString:[Engin shared].imagePath] placeholderImage:[UIImage imageNamed:@"dummyImge.png"]];
当我第一次出现在这个视图中时,我在我的viewdidload函数中添加了这个代码ok first time image update成功,之后我在服务器上更新了一个新的图像,并在上传到服务器上后获取该图像的路径,并将其保存为一个类似这样的单独类

[Engin shared].imagePath = [JSON valueForKey:@"image"];
然后我回到上一个视图,再次在该视图上运行这行代码

[userImage setImageWithURL:[NSURL URLWithString:[Engin shared].imagePath] placeholderImage:[UIImage imageNamed:@"dummyImge.png"]];
但现在这并没有更新图像,而是显示了以前的图像。当我检查该图像的路径时,它们显示更新的(意思是)显示新图像,但当我调用函数时,它们现在显示的是前一个图像的哪个图像路径

NSUrlRequset *request = [NSUrlRequest requestWithURL:[NSURL URLWithString:[Engin shared].imagePath]];

[userImage setImageWithURLRequest:request 
                  placeholderImage:[UIImage imageNamed:@"dummyImge.png"] 
                           success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){
                                  //handle success message here
                                  }
                           failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
                                  //handle error message here
                                  }];

我实际上没有运行此代码,但您可以自己测试。

我如何才能看到我在使用ARC或not在ARC中您不能使用release、retain或AUTORELASE检查此代码是否允许在您的代码中使用或NOOK然后我使用ARC,因为我的代码不允许我release、retain、,自动释放所以下一步我正在使用Afnetroking,并且图像url已成功更新我已检查url放在显示新图像的web视图上,但在UIImageview上,它们显示以前的图像您是否尝试过设置ImageWithUrlRequest:使用Afnetroking的成功块?您可以检查该图像是否正确。因此,请尝试一下,也许您可以在回调块中找到它。