问题描述
在MonoTouch中,你可以得到从ABPerson实例的形象唯一的办法就是使用的原始尺寸返回图像的图像属性。
In Monotouch the only way you can get the Image from an ABPerson instance is using the Image property which returns the image in its original size.
在Objective-C中有一个名为ABPersonCopyImageDataWithFormat(函数http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/func/ABPersonCopyImageDataWithFormat),可从接触返回缩略图图像,
但MonoTouch中没有为此提供有约束力的。
In Objective-C there is a function called ABPersonCopyImageDataWithFormat (http://developer.apple.com/library/ios/#documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/c/func/ABPersonCopyImageDataWithFormat), which can return the thumbnailed image from the contact, but Monotouch does not provide a binding for this.
是否有任何身体知道如何调用在MonoTouch的此功能,或者如何创建它的约束力?
Does any body know how to call this function in Monotouch or how to create its binding?
谢谢,
丹尼
推荐答案
刚刚发现的溶液(disassemling的monotouch.dll,并在内部code仔细看)
Just found the solution (by disassemling the monotouch.dll and look carefully at the internal code)
[DllImport("/System/Library/Frameworks/AddressBook.framework/AddressBook")]
private static extern IntPtr ABPersonCopyImageDataWithFormat(IntPtr handle, ABPersonImageFormat format);
ABPersonImageFormat format = ABPersonImageFormat.Thumbnail;
NSData data = new NSData(ABPersonCopyImageDataWithFormat(person.Handle, format));
UIImage imgThumb = UIImage.LoadFromData(data);
与它好运!
这篇关于MonoTouch的为ABPersonCopyImageDataWithFormat结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!