Datasheet
Book VII
Chapter 1
A User Interface
for Adding Hotels
and Using the
Address Book
775
Interfacing with the Address Book Application
The general outline for using ABPeoplePickerNavigationController is
as follows:
1. Create and initialize an instance of the class.
2. Set the delegate, which must adopt the
ABPeoplePickerNavigationControllerDelegate protocol.
3. Present the People Picker as a modal view controller by using the present
ModalViewController:animated: method.
4. The ABPeoplePickerNavigationController then sends a message
to your delegate based upon a user’s action:
You’ll need to implement three separate delegate methods:
✦ peoplePickerNavigationController:shouldContinueAfter
SelectingPerson:
✦ peoplePickerNavigationController:shouldContinueAfter
SelectingPerson: property:identifier:
✦ peoplePickerNavigationControllerDidCancel:
If the user cancels, the ABPeoplePickerNavigationController sends
the peoplePickerNavigationControllerDidCancel: message to your
delegate, which should dismiss the controller.
If the user selects a contact, the ABPeoplePickerNavigationController
sends the peoplePickerNavigationController:shouldContinue
AfterSelectingPerson: message of the delegate to determine if it should
allow the user to choose a specific property of the selected person. You can
either return YES or NO, although in this case you will return NO.
If the user selects a property, the ABPeoplePickerNavigation
Controller sends the peoplePickerNavigationController:should
ContinueAfterSelectingPerson: property:identifier: message
to the delegate to determine whether it should continue. To perform the
default action for the selected property (dialing a phone number, starting
a new e-mail, and so on), return YES. Otherwise return NO and dismiss the
picker. In this case, you’ll return NO.
You’ll start by having the AddHotelController adopt the
ABPeoplePickerNavigationControllerDelegate protocol. Make the
changes shown in bold in Listing 1-19 to AddHotelController.h.
41_542934-bk07ch01.indd 77541_542934-bk07ch01.indd 775 3/23/10 11:01 PM3/23/10 11:01 PM