iOS头像无法更新
来源:互联网 发布:johnston murphy 淘宝 编辑:程序博客网 时间:2024/06/11 04:58
项目里个人资料有个更换头像的功能,之前有整过这种功能,但是现在一直不能更换成功,最后才注意到不管怎么更换头像,头像的url是不会变的,上网搜解决办法记录如下:
头像不更新的原因:原因: SDWebImage缓存图像会优先从内存读取用户头像,如果内存中没有会从沙盒(也就是硬盘)中读取,如果沙盒中也没有,才会异步从网络上请求头像,如果头像已经存在沙盒或者内存中,SDWebImage就不会从网络上请求,而是加载本地的,会导致头像无法更新。
解决办法:
加载头像的时候用下面的方法
sd_setImageWithURL:<#(NSURL *)#> placeholderImage:<#(UIImage *)#> options:<#(SDWebImageOptions)#> //options用:SDWebImageRefreshCached
同时更改sdwebimage框架里的源码
把if (image && options & SDWebImageRefreshCached) {// force progressive off if image already cached but forced refreshingdownloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;// ignore image read from NSURLCache if image if cached but force refreshingdownloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse;}更改为if(image && options &SDWebImageRefreshCached) {// force progressive off if image already cached but forced refreshingdownloaderOptions &= ~SDWebImageDownloaderProgressiveDownload;// remove SDWebImageDownloaderUseNSURLCache flagdownloaderOptions &= ~SDWebImageDownloaderUseNSURLCache;// ignore image read from NSURLCache if image is cached but force refreshingdownloaderOptions |=SDWebImageDownloaderIgnoreCachedResponse;}
这样就可以解决头像无法更新的问题了。
0 0
- iOS头像无法更新
- CSDN无法更新头像
- 更新头像
- 论坛新手任务中的更新头像任务无法完成
- Cache之过: 网页或头像 无法 同步更新
- iOS实战-头像更新上传之后,UI不刷新
- 今天刚刚更新头像
- ios Xcode更新之后模拟器无法找到?
- iOS开发常见错误:用户头像上传成功但无法更换
- ios 头像上传
- IOS 圆形头像
- iOS 画圆形头像
- ios异步加载头像
- ios 制作方形头像
- iOS 设计圆形头像
- iOS实现圆形头像
- iOS 上传头像
- iOS实现圆形头像
- 教你快速掌握androidstudio使用git上传本地项目到github、版本控制
- Java设计模式之五--单例模式(最全且最简单单例模式罗列)
- Java操作wkhtmltopdf实现Html转PDF
- 【备忘】2016年黑马android安卓74期完整实战开发基础就业视频
- Gradle for Android 系列:初识 Gradle 文件
- iOS头像无法更新
- SpringMVC Controller 介绍
- Android三种开发类型
- SQL语句大全
- FEA从入门到精通系列 | 基础原语分类
- java笔记
- androidstudio git项目到github出现的错误解决办法
- ssl双向认证和单向认证的区别
- 28335串口通信的三种方式