2009-11-18 108 views
0

我正在開發一個應用程序,我必須允許用戶以編程方式編輯聯繫人。編輯iphone中的聯繫信息

我GOOGLE了一下

我發現ABPersonViewController將被使用。我無法找到如何植入它。

地址簿iPhone OS的編程指南也沒有爲我工作。

你能建議我這樣做嗎?

日Thnx提前

回答

0

好吧,我總算找到解決自己

這裏是

-(IBAction)showPicker:(id) sender{ 
    ABAddressBookRef addressBook = ABAddressBookCreate(); 
    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook); 
    ABRecordRef person = CFArrayGetValueAtIndex(allPeople,0); 
    ABPersonViewController *personController = [[ABPersonViewController alloc] init]; 
    personController.displayedPerson = person; 
    personController.addressBook = addressBook; 
    personController.allowsEditing = YES; 
    personController.personViewDelegate = self; 
    UINavigationController *contactNavController = [[UINavigationController alloc] initWithRootViewController:personController]; 
    [personController release]; 
    CFRelease(allPeople); 
    CFRelease(person); 

    [self presentModalViewController:contactNavController animated:YES];  
} 


-(void)personViewControllerDidCancel:(ABPersonViewController *)peoplePicker 
{ 
    [self dismissModalViewControllerAnimated:YES]; 
} 

-(BOOL)personViewController:(ABPersonViewController *)peoplePicker shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID) property identifier:(ABMultiValueIdentifier) identifier 
{ 
    return YES; 
}