ABPeoplePickerNavigationController display all contact data in a single cel

强颜欢笑 提交于 2019-12-12 01:13:21

问题


Hi i am developing a app where when i click contacts it goes to ABpeoplePicekrNavigationcontroller and display all contacts in the form of list in the table.But i want to select all contacts so that i want to perform some action.So how can i achive this.

I am not sure this is the right question to ask.Actually i am trying to send the contact information to next screen instead of selecting single contact information everytime i want to select whole contact list.So how can i do this??

I thought i show them to show in single cell even though space doesnt fit in single cell.just show them single cell so that selecting one cell which contains all contact information would be better to send..

So can anyone suggest me right way to select all the contacts list rather than selecting one contact..I donno whether we can do this or not??if so how???if not what is the other way?? Here is the below code where i am using for accessing the contact list.

- (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;
}

回答1:


You can get your record using this

- (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);
}


来源:https://stackoverflow.com/questions/16815238/abpeoplepickernavigationcontroller-display-all-contact-data-in-a-single-cel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!