gpt4 book ai didi

iphone - ABPersonSetImageData 仅更改联系人缩略图而不是完整图片

转载 作者:行者123 更新时间:2023-12-03 18:44:35 26 4
gpt4 key购买 nike

我正在尝试在每张联系人照片周围添加边框。我有创建此边框图像的工作代码和将其设置为联系人图像的工作代码:

if (image) {
NSData *dataRef = UIImagePNGRepresentation(image);
CFDataRef cfdata = CFDataCreate(NULL, [dataRef bytes], [dataRef length]);
CFErrorRef error;
ret = ABPersonSetImageData(person, cfdata, &error);
if (ret) {
ret = ABAddressBookSave(addressBook, &error);
} else {
DebugLog(@"Could not write the image to the person: %@", [error description]);
}
CFRelease(cfdata);
}

我看到的问题是,虽然在“联系人”或“电话”应用程序中查看时缩略图中可以正确显示带边框的图像,但来电时显示的全屏图像却无法正确显示。

我原本以为它只是放大了一点,所以我尝试了边框大小。我确认大镜头上根本没有显示边框。我是否遗漏了一些明显的东西?

<小时/>

编辑 2009 年 10 月 9 日我一直在与Apple沟通,这确实是Address Book框架中的一个错误。如果您正在阅读这篇文章,那么我建议您file a bug with Apple at 帮助加快修复速度。

最佳答案

我将在这里回答我自己的问题,因为我想我已经弄清楚问题是什么了。如果您的联系人还没有图像,则当您使用 ABPersonSetImageData 时,将会添加缩略图和全尺寸照片。如果您的联系人已有全尺寸图像,则当您使用 ABPersonSetImageData 时,只会设置缩略图。

意识到这一点后,解决方案就很简单了。我只是在设置之前删除了图片。

if (image) {
NSData *dataRef = UIImagePNGRepresentation(image);
CFDataRef cfdata = CFDataCreate(NULL, [dataRef bytes], [dataRef length]);
CFErrorRef error;

ABPersonRemoveImageData(person, &error); // <-- clean any image first from ref
ABAddressBookSave(addressBook, &error);

ret = ABPersonSetImageData(person, cfdata, &error);
if (ret) {
ret = ABAddressBookSave(addressBook, &error);
} else {
DebugLog(@"Could not write the image to the person");
}
CFRelease(cfdata);
}

注意*

This creates a square version of the full-sized pic. The processcrops the top and bottom off of the image and sets it to be 320x320.But, it is working.

编辑 2009 年 10 月 9 日

I have been in communications with Apple and this is indeed a bug inthe Address Book framework. If you are reading this post, then Isuggest you file a bug with Apple at to help expedite the fix.

关于iphone - ABPersonSetImageData 仅更改联系人缩略图而不是完整图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1527658/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com