我需要从地址簿中获取每个联系人的图像 url。我现在可以获取图像,但问题是我需要为特定的人获取图像的 Assets URL。目前我正在通过
获取联系人图片[UIImage imageWithData:(__bridge NSData *)ABPersonCopyImageData(person)]
请帮助我获取该特定图像的 Assets URL。谢谢
最佳答案
我认为您需要制作数据的本地副本,然后在您的数据库中保存对该本地副本的引用:
//create a fileName perhaps based on the contact name or a GUID
NSError *err;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);//find the cache dir. You might want to consider using the doc dir instead
NSString * path = [paths objectAtIndex:0];
path = [path stringByAppendingPathComponent:fileName];
[imgData writeToFile:path options:NSDataWritingAtomic error:&err];
if(!err)
{
///save path to the DB
}
关于ios - 如何从联系人中获取联系人图片 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20784323/