MonoTouch的为ABPersonCopyImageDataWithFormat结合(Monot

2019-10-16 13:37发布

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.

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.

Does any body know how to call this function in Monotouch or how to create its binding?

Thanks, Danny

Answer 1:

只要找到了解决办法(由disassemling的monotouch.dll,并在内部代码仔细看)

[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);

与它的好运气!



Answer 2:

它必将为MonoTouch.AddressBook.ABPerson.CopyImage (ABPersonImageFormat format);



文章来源: Monotouch binding for ABPersonCopyImageDataWithFormat