UIImage*image=[UIImage imageNamed:@"star_full.png"];
NSData*data=UIImagePNGRepresentation(image);
ABPersonRemoveImageData(person, NULL);
CFDataRef cfData=CFDataCreate(NULL, [databytes], [data length]);
ABPersonSetImageData(person, cfData, nil);
但是只能临时修改,这里需要一次保存的过程
UIImage*image=[UIImage imageNamed:@"star_full.png"];
ABAddressBookRefaddressbook = ABAddressBookCreate();
NSData*data=UIImagePNGRepresentation(image);
ABPersonRemoveImageData(person, NULL);
CFDataRef cfData=CFDataCreate(NULL, [databytes], [data length]);
ABPersonSetImageData(person, cfData, nil);
ABAddressBookAddRecord(addressbook, person,nil);
ABAddressBookSave(addressbook, nil);
上面的代码可以添加联系人头像,但是未能实现修改联系人头像功能,这里还缺少一步
UIImage*image=[UIImage imageNamed:@"star_full.png"];
ABAddressBookRef addressbook = ABAddressBookCreate();
NSData*data=UIImagePNGRepresentation(image);
ABPersonRemoveImageData(person, NULL);
ABAddressBookAddRecord(addressbook, person,nil);
ABAddressBookSave(addressbook, nil);
CFDataRef cfData=CFDataCreate(NULL, [databytes], [data length]);
ABPersonSetImageData(person, cfData, nil);
ABAddressBookAddRecord(addressbook, person,nil);
ABAddressBookSave(addressbook, nil);
在删除联系人头像后需要保存一次才可以成功
这样就完美的解决了