从iphone应用程序中的地址簿中获取照片 [英] Get photos from Address book in iphone Application
本文介绍了从iphone应用程序中的地址簿中获取照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的iphone应用程序中获取联系人姓名,来自Addressbook的照片。我能够获得联系人并存储到数组中。但现在知道如何获取联系人照片。我使用的代码如下。
I want to get contact name,photos from Addressbook in my iphone application. I am able to get contacts and store in to array.but now know how also get contacts photos.the code i am using is as follows.
ABAddressBookRef ab=ABAddressBookCreate();
NSArray *arrTemp=(NSArray *)ABAddressBookCopyArrayOfAllPeople(ab);
arrContact=[[NSMutableArray alloc] init];
for (int i=0;i<[arrTemp count];i++)
{
NSMutableDictionary *dicContact=[[NSMutableDictionary alloc] init];
NSString *str=(NSString *) ABRecordCopyValue([arrTemp objectAtIndex:i], kABPersonFirstNameProperty);
@try
{
[dicContact setObject:str forKey:@"name"];
}
@catch (NSException * e) {
[dicContact release];
continue;
}
[arrContact addObject:dicContact];
NSLog(@"mohit inside the loop");
[dicContact release];
}
我想在该数组中获取联系人照片和姓名(arrContacts)然后在表格中显示它们。请给我指导。谢谢
I want to to get both contacts photo and name in that array(arrContacts) then display them in table. Please give me guideline. Thanks
推荐答案
在ARC模式下
NSData *imgData = (__bridge_transfer NSData *) ABPersonCopyImageDataWithFormat(record, kABPersonImageFormatThumbnail);
其中record是类的对象
where record is the object of class
ABRecordRef
希望这有助于
这篇关于从iphone应用程序中的地址簿中获取照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文