gpt4 book ai didi

iPhone ABPeoplePickerNavigationController - 如何从地址簿中选择一个人的两个不同多值属性的两个单个条目

转载 作者:太空狗 更新时间:2023-10-30 03:23:46 26 4
gpt4 key购买 nike

几周来我一直在寻找解决方案,这让我几近绝望。

问题很简单:

  • 通过 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,但我不知道怎么做。

如果有人有任何想法那就太好了!

如果你想看到这样的行为,你可以看看亚马逊应用程序:如果你完成订单的第一步,你可以完全按照这种方式选择送货地址:从联系人列表 -> 选择一个人员 -> 选择地址 -> 选择电话号码。在那里,一切(似乎)都发生在模态视图中,只有一个导航层次结构比上面显示的标准代码多了一个层次。

最佳答案

我想这可能是你想要的:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{

ABPersonViewController *controller = [[ABPersonViewController alloc] init];
controller.displayedPerson = person;
controller.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonPhoneProperty]];
controller.personViewDelegate = self;
[peoplePicker pushViewController:controller animated:YES];
[controller release];
return NO;
}

- (BOOL)personViewController:(ABPersonViewController *)personViewController
shouldPerformDefaultActionForPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifierForValue
{
ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
CFStringRef phone = ABMultiValueCopyValueAtIndex(multi, identifierForValue);
NSLog(@"phone %@", (NSString *)phone);
CFRelease(phone);

ABPeoplePickerNavigationController *peoplePicker = (ABPeoplePickerNavigationController *)personViewController.navigationController;
[peoplePicker dismissModalViewControllerAnimated:YES];
return NO;
}

想法是,创建另一个 ABPersonViewController 实例,并让您的人员选择器推送它,因为 ABPeoplePickerNavigationController 是 NSPeoplePickerNavigationController 的子类。

关于iPhone ABPeoplePickerNavigationController - 如何从地址簿中选择一个人的两个不同多值属性的两个单个条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2330615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com