2009-06-24 43 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

相關問題