在MyViewController
中,我要求用户从通讯录中选择一个人:(单击按钮)
peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
peoplePicker.peoplePickerDelegate = self;
[self presentViewController:peoplePicker animated:YES completion:NULL];
如果用户选择一个拥有多个电话号码的人,我将展示一个新的 UITableViewController,它允许用户选择一个电话号码:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
// ...
next = [[ChoosePersonPhoneViewController alloc] initWithStyle:UITableViewStyleGrouped personPhoneInfoArray:personPhoneInfos];
[peoplePicker pushViewController:next animated:YES];
// ...
}
当用户选择一个电话号码时,我想将该电话号码带回原来的 ViewController 并关闭两个ABPeoplePickerNavigationController
and ChoosePersonPhoneViewController
。
两个问题:
- 如何从内部关闭两个视图控制器
ChoosePersonPhoneViewController
? - 我如何
MyViewController
从内部访问ChoosePersonPhoneViewController
?
我的猜测是:
ABPeoplePickerNavigationController *peoplePicker = (ABPeoplePickerNavigationController *)self.navigationController;
MyViewController *nsvc = (MyViewController *)peoplePicker.presentingViewController;
我尝试了许多使用parentViewController
andpresentingViewController
和popViewController
/的组合dismissViewController
,但无法真正弄清楚 - 我不断收到异常,这表明我对视图控制器层次结构缺乏了解。我将不胜感激一些指针或至少 RTFM 链接。