0

I have build an app that has a user profile. The user can change his profile image by uploading his new one.

The app also has a table view where all users upload their posts. When send/upload a new post or the article it will appear in this table with the user name and his profile image (something like Twitter or Instagram).

The problem is that when the user change his profile image, It does not change in the table where he posted his article. I can check the profile directly through the internet explorer and it shows the new image.

I am using the code below to show the image in the table:

  [myCell.userImage sd_setImageWithURL:[NSURL URLWithString:item.userImageUpload]
                        placeholderImage:[UIImage imageNamed:@"video_no_image.jpg"]options:SDWebImageRefreshCached];

I hope to find the problem. Thanks

Ahmed Alkaabi
  • 61
  • 1
  • 7
  • Make sure you are getting updated url of image in `item.userImageUpload` after updating image. – Rajat Nov 08 '16 at 08:39
  • I do. I am updating all data. and I can see the new image from my browser – Ahmed Alkaabi Nov 08 '16 at 08:41
  • also i am not using a new Url, It is always the same Url. I am just uploading the new profile image which will replace the old one with the same Url – Ahmed Alkaabi Nov 08 '16 at 08:43
  • @AhmedAlkaabi : SDWebimage normally works like this, If he got the URL, and related to that url if image not available then it will download and store it in catch. In your case Url is not changing to it is returning the old image. Try to remove the cache and you will be good to go – Wolverine Nov 08 '16 at 08:47
  • How can I remove the cache? – Ahmed Alkaabi Nov 08 '16 at 08:48
  • You can remove Individual Image catch by checking this answer http://stackoverflow.com/questions/11888578/xcode-sdwebimage-clear-cache-for-single-image – Wolverine Nov 08 '16 at 08:50
  • And to remove complete cache you should prefer this answer http://stackoverflow.com/questions/13865537/sdwebimage-clearing-cache – Wolverine Nov 08 '16 at 08:50
  • You don't need to remove the cache just update the URL of that image which you will get in the response while updating the image, in that way you will get a new image on your image view – Rajat Nov 08 '16 at 08:52
  • i am quite sure that you have some thing wrong in url try nslog the url of image, make sure it doesnot contain any space or + symbols inside it, because if url is invalid sdwebimage doesnot displays image, but on browser you can preview the image without encoding the url, so in that case you also need to encode the url manually to get image – ShujatAli Nov 08 '16 at 08:55
  • The Url is correct. Sometimes the image will update after 1 hour. sometime it takes longer and sometime it does not update – Ahmed Alkaabi Nov 08 '16 at 08:59
  • @shujatAli The Url is correct. Sometimes the image will update after 1 hour. sometime it takes longer and sometime it does not update – Ahmed Alkaabi Nov 08 '16 at 09:16
  • What is the size of the image which you are getting from url ? – Rajat Nov 08 '16 at 09:35
  • @Rajat the size is 592,216 bytes – Ahmed Alkaabi Nov 08 '16 at 09:54

0 Answers0