我正在开发一个使用 ABPeopleViewController 的应用程序,我想在用户最终选择联系人时,向后退两个视图控制器。这是我到达 ABPeoplePickerNavigationController 的方式:点击主视图控制器的按钮 -> 加载模式(对话框)视图控制器 -> 点击模式视图控制器的按钮 -> 加载 ABContacts。
我正在模态视图中实现 ABContacts 的委托,而该委托又在主视图控制器中有一个委托。
我想从 ABPeoplePicker 委托方法返回到主视图控制器。
希望这能理解,有人可以帮助我,我没有找到这样的东西。
我的 MainViewController.h:
@protocol ModalViewDialogDelegate
- (void)didReceiveMail:(NSString *)mail;
@end
@interface SetUpViewController : UIViewController<UITextFieldDelegate, ModalViewDialogDelegate>{
}
//...
我的 MainViewController.m:
//...
- (void)didReceiveMail:(NSString *)mail{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
//...
我的模态视图.h:
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
@protocol ModalViewDialogDelegate;
@interface DialogViewController : UIViewController<ABNewPersonViewControllerDelegate, ABPeoplePickerNavigationControllerDelegate>{
id<ModalViewDialogDelegate> delegate;
}
@property (nonatomic, assign) id<ModalViewDialogDelegate> delegate;
@property (nonatomic, retain) NSString * mailSelected;
//...
我的 modalView.m:
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
//...here i get the email person property and then i want to go backwards to the main view controller, not the modal.
[self dismissViewControllerAnimated:YES completion:nil];
//don't know if it's ok like this, because in the implementation also dismiss presented viewcontroller.
[_delegate didReceiveMail:self.mailSelected];
return NO;
}
return YES;
}