1

我想在我的 AS3 应用程序中获取 iPhone 和 android 电话簿中的所有联系人。如何在 as3 中做到这一点?

-提前致谢

4

2 回答 2

2

您将需要使用本机扩展。

看看这个:

https://github.com/memeller/ContactEditor

于 2012-04-07T16:03:49.830 回答
0

对于 iPhone,首先您必须添加 Addressbook 和 AddressbookUI 框架。

然后,为了获取联系人,您必须实现以下方法......

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier

然后,,- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

最后- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker

现在,return NO第二种方法中设置,调用一种方法....就像

[self displayContact:person];
[self dismissModalViewControllerAnimated:YES];
return NO;

在第三个视图中,设置这个..[self dismissModalViewControllerAnimated:YES];

现在,对于那个方法...

-(void)displayContact:(ABRecordRef)person
{

name = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
lblname.text = name;

ABMultiValueRef phNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if(ABMultiValueGetCount(phNumbers) > 0)
{
    //NSLog(@"Count is:%ld",ABMultiValueGetCount(phNumbers));
    phone = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(phNumbers, 0);
    btnsms.hidden = NO;
    btnedit.hidden = NO;
}
else
{
    phone = @"[NONE]";
}

lblphno.text = phone;

}

通过实现这一点,您可以在标签中看到姓名和电话号码......:)

于 2012-04-07T10:09:08.880 回答