How to acess contacts of iPhone in IOS 6

后端 未结 3 1443
一整个雨季
一整个雨季 2021-01-03 16:53

I want to show contacts and details of contacts in my application.List of contacts and after selecting any contact details of that contact will show on next page using addre

3条回答
  •  离开以前
    2021-01-03 17:17

    Add Framwork

    #import 
    #import 
    #import 
    

    use delegate

     
    

    You can show your contact by ABPeoplePickerNavigationController

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
            [[picker navigationBar] setBarStyle:UIBarStyleBlack];
            picker.peoplePickerDelegate = self;
            // Display only a person's phone, email, and birthdate
            NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty],nil];
    
            picker.displayedProperties = displayedItems;
            // Show the picker
            [self presentModalViewController:picker animated:YES];
            [picker release];   
    

    and after you initialize then you need to use following method

    #pragma mark - ABPeopelPickerNavigationController Delegate and DataSource Methods
    
    - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
    {
        [self dismissModalViewControllerAnimated:YES];
    }
    
    - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
    {
       // For get People detail
    }
    
    - (void)unknownPersonViewController:(ABUnknownPersonViewController *)unknownCardViewController didResolveToPerson:(ABRecordRef)person
    {
    }
    
    - (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person
    {
    }
    
    - (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
    {
        return YES;
    }
    
    - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;
    {
        return YES;
    }
    

提交回复
热议问题