我已经快要绝望了,因为我已经寻找了数周的解决方案。
问题很简单:
- 通过 ABPeoplePickerNavigationController(作为 ModalView),应该选择一个人。
- 然后只有(例如)邮件地址应该被显示并且用户应该选择一个。
- 在选择了一个邮件地址之后,应该只显示(例如)电话号码,并且用户应该选择一个。
直到第三个方面的解决方案是众所周知的:
- (IBAction)importFromAddressBook
{
ABPeoplePickerNavigationController* picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
[peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]]];
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
//===PROBLEM=== Now I do have a mail address and I want to have a phone number right afterwards.
//Something like this would be straightforward, but the view does not change this way:
[peoplePicker setDisplayedProperties:[NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]]];
//Here misses the important code.
//And only when I also got a phone number through this or a similar method I want to call:
[peoplePicker dismissModalViewControllerAnimated:YES];
//I do not want to start default behaviour with the mailaddress and/or phone number:
return NO;
}
正确的做法似乎是在ModalView的NavigationController上推了一个类似的peoplePicker View,但是我不知道怎么做。
如果有人有任何想法,那就太好了!
如果你想看到这样的行为,你可以看看亚马逊应用程序:如果你完成订单的第一步,你可以通过这种方式选择送货地址:从联系人列表 -> 选择一个人 ->选择地址 -> 选择电话号码。在那里,一切(似乎)都发生在模态视图中,只有一个比上面显示的标准代码多一级的导航层次结构。