我正在使用setImageWithURL我的应用程序下载一些图像.可能吗:
关于这些问题,文件并不是很清楚.
我试图通过使用AFImageCache来缓存从URL加载的一些图像,但没有成功...我不确定如果我做错了什么并且如果你曾经使用过这个库就会喜欢你的意见.
我从NSURLRequest获取图像,然后按如下方式缓存它
UIImage *img; //This image is a png icon returned from the server
NSData *imgData = UIImagePNGRepresentation(img); // Always checking length to make sure its more than 0, and it is
[[AFImageCache sharedImageCache] cacheImageData: imgData
forURL: myURL
cacheName: @"IconCache"];
Run Code Online (Sandbox Code Playgroud)
在下一次运行中,我将尝试检查图像是否已缓存,但nil由于某种原因总是会得到.
UIImage *myIcon = [[AFImageCache sharedImageCache] cachedImageForURL: myURL cacheName: @"IconCache"];
NSLog("%@", myIcon); // output (null)
Run Code Online (Sandbox Code Playgroud)
有关于此的任何想法或想法?谢谢.