怎么修改用户的昵称和头像,leancloud本身带昵称和头像吗,还是用自己服务器上的
-
创建时间
16年5月1日
-
最后回复
16年5月6日
-
8
回复
-
3.3K
浏览
-
2
用户
-
1
赞
import "AVUser+Avatar.h"
define kAttrKey_AvatarFile @"avatarFile"
@implementation AVUser (Avatar)
(NSString*)avatarUrl {
AVFile *avatarFile = [self objectForKey:kAttrKey_AvatarFile];
return [avatarFile url];
}
(void)updateAvatarWithImage:(UIImage*)image callback:(AVBooleanResultBlock)block{
AVFile *oldFile = [self objectForKey:kAttrKey_AvatarFile];
AVFile *newFile = [AVFile fileWithData:UIImagePNGRepresentation(image)];
[newFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
///失败
if (!succeeded) {
if (block) {
block(succeeded, error);
};
return;
}
///成功
[self setObject:newFile forKey:kAttrKey_AvatarFile];
[self saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
[oldFile deleteInBackground];
}
if (block) {
block(succeeded, error);
}
}];
}];
}
主题 | 分类 | 回复 | 浏览 | 活动 |
---|---|---|---|---|
咨询有关测试手机号码的问题? | 实时通信 | 3 | 1.1K | 15-09-24 |
uniapp开发小程序即时通讯一对一收不到被加入会话提示 | 实时通信 | 1 | 1.1K | 22-08-12 |
没有找到isUnique属性 | 实时通信 | 0 | 822 | 16-09-17 |
如果conversation被删除了,仍然返回发送成功 | 实时通信 | 1 | 1.0K | 16-06-28 |
“发送短信过于频繁” | 实时通信 | 0 | 808 | 16-09-4 |