我想添加一些地址簿功能到我的應用程序,但點擊第二次'添加到現有'按鈕後,我收到此錯誤消息。在iOS AddressBookUI - '不應該試圖顯示多個Add to Existing Contact people picker。「
*斷言故障 - [ABPersonViewControllerHelper presentPeoplePickerNavigationControllerForAddToContacts:],/SourceCache/AddressBookUI_Sim/AddressBookUI-1118/ABPersonViewControllerHelper.m:2574 2011-10-24 20:41:11.960 locato [4576:11603] 終止應用程序,由於未捕獲異常'NSInternalInconsistencyException',原因:'不應嘗試顯示多個Add to Existing Contact people picker。 第一擲調用堆棧: (0x152e052 0x16bfd0a 0x14d6a78 0xefd2db 0x9d674 0x152fe72 0xd0eb8 0xc8141 0xb9e2f 0x60471d 0x604952 0xe8c86d 0x1502966 0x1502407 0x14657c0 0x1464db4 0x1464ccb 0x17eb879 0x17eb93e 0x574a9b 0x22d9 0x2255) 終止叫做拋出異常
我有一個視圖控制器和一個導航控制器,以及im在主視圖控制器上顯示地址簿的「模態」視圖。 (否則我沒有得到滑動過渡,這個錯誤。)。我已經覆蓋了這些方法:
@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];
}
我希望得到一些什麼我沒做正確的澄清!
感謝, 大衛
感謝您的幫助,響應者不是零,它是主要的視圖控制器。當我不使用'scr'對象時編譯器給我一個錯誤,因爲它認爲屏幕是一個UIViewController而不是ABPeoplePickerNavigationController ..我認爲問題是當im解僱ABPeoplePickerNavigationController時缺少某些東西..但是我不能它是什麼.. – david
你可以在2574行顯示ABPersonViewControllerHelper.m嗎?另一件事,'屏幕setPeoplePickerDelegate:自己];'工作? –
我不能告訴你ABPersonViewControllerHelper.m,因爲它在AddressBookUI框架中。不幸的是'[screen setPeoplePickerDelegate:self];'不工作,因爲編譯器仍然認爲屏幕是一個uiviewcontroller。 :( – david