2009-06-24 49 views
1

我试图建立一个应用程序,允许用户A)输入一个新的人,或B)从他们的联系人中选择一个人......我的问题是项目B.我简要地阅读了关于加载Modal视图控制器的内容,但是希望有人能够指导我参考教程或文章的方向,专门讨论这种用例场景。iPhone:选择一个联系人并加载到自定义应用程序

是的,我对iPhone应用程序开发也有点新意。

回答

5
  1. 您的视图控制器应该实现ABPeoplePickerNavigationControllerDelegate协议
  2. 您展现peoplepicker是这样的:
ABPeoplePickerNavigationController *peoplePickerController = 
    [[ABPeoplePickerNavigationController alloc] init]; 
    peoplePickerController.peoplePickerDelegate = self; 

    [self presentModalViewController:peoplePickerController animated:YES]; 

    [peoplePickerController release]; 
3. And you might want to implement the optional methods as: 

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

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 
{ 
    NSString *name = (NSString *)ABRecordCopyCompositeName(person); 
    // do something with name.. and release 

    [self dismissModalViewControllerAnimated:YES];  

    return NO; 
} 

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

是的,谢谢你的回答 - 我发现有人实施了这套完整的方法。 正是我需要的。 – Ixmatus 2009-06-25 21:30:52

相关问题