私はABPeopleViewControllerを使用するアプリを開発していますが、ユーザーが連絡先の選択を完了したら、前に2つのviewcontrollerに戻りたいと思います。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];
//...
私の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;
}