2011-05-25 25 views
0

如何將聯繫人添加到'人員'數組然後到abrecordref。其實我想在tableview中的所有聯繫人,並能夠編輯個人記錄。這裏是我的代碼:在ABRecordRef中添加數組形式的所有人

-(void)showPersonViewController 
{  
    // Fetch the address book 
     ABAddressBookRef addressBook = ABAddressBookCreate(); 
     // Search for the person named "rubal" in the address book 
     NSArray *people = (NSArray *)ABAddressBookCopyPeopleWithName(addressBook, CFSTR("naina")); 
     // Display "KETAN" information if found in the address book 
     if ((people != nil) && [people count]) 
     { 
      ABRecordRef person = (ABRecordRef)[people objectAtIndex:0]; 
      ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease]; 
      picker.personViewDelegate = self; 
      picker.displayedPerson = person; 
      // Allow users to edit the person’s information 

      picker.allowsEditing = YES; 
      [self.navigationController pushViewController:picker animated:YES]; 
     } 
     else 
     { 
      // Show an alert if "KETAN" is not in Contacts 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
                 message:@"Could not find naina in the Contacts application" 
                 delegate:nil 
                cancelButtonTitle:@"Cancel" 
               otherButtonTitles:nil]; 
      [alert show]; 
      [alert release]; 
     } 
      [people release]; 
      CFRelease(addressBook); 
} 

,而不是隻有「奈娜」我想在表視圖所有記錄和編輯在ABPerson類參考單獨

回答

0

看。還有其他複印功能,包括你所尋求的一個列表,你的功能ABAddressBookCopyArrayOfAllPeople(ABAddressBookRef ab)

0

評論,並添加這一個,看看它是否

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


      [peoplePicker dismissModalViewControllerAnimated:NO]; 

      ABPersonViewController *picker = [[ABPersonViewController alloc] init]; 
      picker.personViewDelegate = self; 
      picker.displayedPerson = person; 

// Allow users to edit the person’s information 
      picker.allowsEditing = YES; 
      [picker setValue:[NSNumber numberWithBool:YES] forKey:@"allowsDeletion"]; 



      [self.navigationController pushViewController:picker animated:YES]; 

    return YES; 
} 
相關問題