我正在开发一个应用程序,它使用ABPeopleViewController,并且我想当用户敲定选择联系人时,向后退回两个viewcontroller。 以下是我如何到达ABPeoplePickerNavigationController: 点击主视图控制器的按钮 - >加载模态(对话框)视图控制器 - >点击模态视图控制器的按钮 - >加载ABContacts。如何从ABPeoplepicker委托方法之前返回两个viewControllers
我在模态视图中实现了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];
//...
我ModalView.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;
}
非常感谢您!它通过在委托方法中调用dismissModalViewController两次来工作! – sheinix 2012-07-20 02:03:35