0

嗨,我正在开发一个应用程序,当我单击联系人时,它会转到 ABpeoplePicekrNavigationcontroller 并以列表的形式在表格中显示所有联系人。但我想选择所有联系人以便我想执行一些操作。那么我该如何实现这个.

我不确定这是要问的正确问题。实际上,我正在尝试将联系信息发送到下一个屏幕,而不是每次我想选择整个联系人列表时都选择单个联系信息。那么我该怎么做呢?

我以为即使空间不适合单个单元格,我也会让它们显示在单个单元格中。只需向它们显示单个单元格,以便选择一个包含所有联系信息的单元格会更好地发送..

所以任何人都可以建议我选择所有联系人列表而不是选择一个联系人的正确方法。我不知道我们是否可以这样做?这是我用于访问联系人列表的以下代码。

- (IBAction)configureMyContact:(id)sender {
ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
peoplePicker.peoplePickerDelegate = self;
peoplePicker.navigationBar.topItem.title = NSLocalizedString(@"CHOOSE_CONTACT_TITLE", @"Defining my contact title.");
[self presentModalViewController:peoplePicker animated:YES];
[peoplePicker release];
}


- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker {
[self dismissModalViewControllerAnimated:YES];
}


- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker 
  shouldContinueAfterSelectingPerson:(ABRecordRef)person {

myContactID = ABRecordGetRecordID(person);
[self refreshMyContactButton];
[self saveMyContactID:myContactID];

[self dismissModalViewControllerAnimated:YES];

return NO;
}

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker 
  shouldContinueAfterSelectingPerson:(ABRecordRef)person
                            property:(ABPropertyID)property
                          identifier:(ABMultiValueIdentifier)identifier{
return NO;
}
4

1 回答 1

0

你可以使用这个来获取你的记录

- (void)getPersonOutOfAddressBook
{    
    ABAddressBookRef addressBook = ABAddressBookCreate();

    if (addressBook != nil)
    {
        NSLog(@"Succesful.");

        NSArray *allContacts = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);

        NSUInteger i = 0;
        for (i = 0; i < [allContacts count]; i++)
        {            
            ABRecordRef contactPerson = (__bridge ABRecordRef)allContacts[i];



            NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty);

            NSString *lastName =  (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonLastNameProperty);

            ABMultiValueRef mobile=ABRecordCopyValue(contactPerson, kABPersonPhoneProperty);

            for (int k=0;k<ABMultiValueGetCount(mobile); k++)
            {
                NSString *mobileNo = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(mobile, k);
            }


            //email
            ABMultiValueRef emails = ABRecordCopyValue(contactPerson, kABPersonEmailProperty);

            NSUInteger j = 0;
            for (j = 0; j < ABMultiValueGetCount(emails); j++)
            {
                NSString *email = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(emails, j);
            }

        }
    }
    CFRelease(addressBook);
}
于 2013-05-29T13:44:45.647 回答