アプリにアドレス帳機能を追加しようとしていますが、[既存に追加] ボタンを 2 回タップすると、このエラー メッセージが表示されます。
* -[ABPersonViewControllerHelper presentPeoplePickerNavigationControllerForAddToContacts:]、/SourceCache/AddressBookUI_Sim/AddressBookUI-1118/ABPersonViewControllerHelper.m:2574 2011-10-24 20:41:11.960 locato[4576:11603] でのアサーションの失敗 キャッチされていない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。 First throw call stack: (0x152e052 0x16bfd0a 0x14d6a78 0xefd2db 0x9d674 0x152fe72 0xd0eb8 0xc8141 0xb9e2f 0x60471d 0x604952 0xe8c86d 0x1502966 0x1502407 0x14657c0 0x1464db4 0x1464ccb 0x17eb879 0x17eb93e 0x574a9b 0x22d9 0x2255) terminate called throwing an exception
ビューコントローラーとナビゲーションコントローラーがあり、メインのビューコントローラーにアドレスブックの「モーダル」ビューを表示しています。(または、スライド遷移が得られず、このエラーが発生します。)これらのメソッドをオーバーライドしました:
@implementation UIViewController (cancelButton)
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker;
{
UIResponder *responder = self;
while (responder && ![responder isKindOfClass:[mainViewController class]]) {
responder = [responder nextResponder];
}
[(UIViewController *)responder dismissModalViewControllerAnimated:YES];
}
@end
@implementation UINavigationController (modal)
- (void) presentModalViewController:(UIViewController *)screen animated:(BOOL)animated
{
UIResponder *responder = self;
while (responder && ![responder isKindOfClass:[mainViewController class]]) {
responder = [responder nextResponder];
}
if ([screen isKindOfClass:[ABPeoplePickerNavigationController class]]) {
ABPeoplePickerNavigationController *scr = screen;
scr.peoplePickerDelegate = self;
[scr release];
}
[(UIViewController *)responder presentModalViewController:screen animated:YES];
}
私が正しく行っていないことについて、いくつかの説明を得たいと思っています!
ありがとう、デビッド