- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在每张联系人照片周围添加边框。我有创建此边框图像的工作代码和将其设置为联系人图像的工作代码:
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/
我使用 ABUnknownPersonViewController 来显示联系人 View 。 我尝试设置图像: NSData *dataRef = UIImagePNGRepresentation(
我正在尝试在每张联系人照片周围添加边框。我有创建此边框图像的工作代码和将其设置为联系人图像的工作代码: if (image) { NSData *dataRef = UIImagePNGRep
我正在开发一个与 AddressBook 联系人一起使用的 iPhone 应用程序。我正在尝试从地址簿中获取图像并进行编辑,然后保存该图像。 但我不知道如何更新和保存该图像。如果有人知道这一点,请给我
我是一名优秀的程序员,十分优秀!