문제

I'm having trouble with refreshing a nimbus image and not sure if I'm correctly removing the cached images. After I upload a new image it still keeps showing the old image on refresh for a few minutes or more.

[(SDURLCache*)[NSURLCache sharedURLCache] removeCachedResponseForRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];

[[Nimbus imageMemoryCache] removeObjectWithName:url];

[profilePic setPathToNetworkImage:url];

Which way is the right way to remove the cache?

도움이 되었습니까?

해결책

I've added a new method to Nimbus' in-memory cache called removeAllObjectsWithPrefix:. You can use this method in the following way to forcefully expire images from the cache:

[imageView.imageMemoryCache removeAllObjectsWithPrefix:imageUrl];

You will need to know the url in order to expire it from the cache.

The reason why this method is necessary is because NINetworkImageView adds a suffix to the image cache key to differentiate between different sizes and content modes.

https://github.com/jverkoey/nimbus/blob/master/src/networkimage/src/NINetworkImageView.m#L137

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top