iOS AddressBookUI - “不应尝试显示多个“添加到现有联系人”人员选择器。”

发布于 2024-12-11 19:11:33 字数 1861 浏览 3 评论 0原文

我正在尝试向我的应用程序添加一些地址簿功能,但在第二次点击“添加到现有”按钮后,我收到此错误消息。

* -[ABPersonViewControllerHelper presentPeoplePickerNavigationControllerForAddToContacts:]、/SourceCache/AddressBookUI_Sim/AddressBookUI-1118/ABPersonViewControllerHelper.m:2574 中断言失败 2011-10-24 20:41:11.960 定位[4576:11603] 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“不应尝试显示多个“添加到现有联系人”人员选择器。” 第一个抛出调用堆栈: (0x152e052 0x16bfd0a 0x14d6a78 0xefd2db 0x9d674 0x152fe72 0xd0eb8 0xc8141 0xb9e2f 0x60471d 0x604952 0xe8c86d 0x1502966 0x1502407 0x14657c0 0x1464db4 0x1464ccb 0x17eb879 0x17eb93e 0x574a9b 0x22d9 0x2255) 终止称为抛出异常

我有一个视图控制器和一个导航控制器,我在主视图控制器上显示地址簿的“模态”视图。 (否则我无法获得滑动过渡,并且出现此错误。)。我已经重写了这些方法:

 @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];
}

我希望得到一些关于我做错了什么的澄清!

谢谢, 大卫

I'm trying add some addressbook functionality to my app, but after tap the second time to the 'Add to existing' button I get this error message.

* Assertion failure in -[ABPersonViewControllerHelper presentPeoplePickerNavigationControllerForAddToContacts:], /SourceCache/AddressBookUI_Sim/AddressBookUI-1118/ABPersonViewControllerHelper.m:2574
2011-10-24 20:41:11.960 locato[4576:11603]
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Shouldn't be trying to show more than one Add to Existing Contact people picker.'
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

I have a viewcontroller and a navigationcontroller, and im displaying the addressbook's 'modal' views on the main viewcontroller. (or else im not getting the sliding transition, and this error.). I have overridden these methods:

 @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];
}

Im hoping to get some clarification on what im not doing right!

thanks,
David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朱染 2024-12-18 19:11:33

在再次尝试之前,您可以更改两件事:

  • 在两个 while 循环之后,在执行关闭或呈现视图控制器之前检查响应者是否为 nil

  • 你不能只分配 screen.peoplePickerDelegate = self;代码>而不是使用这个scr?

Two things you could change before trying again:

  • after both while loops, check that responder is not nil before doing dismiss or present a viewcontroller

  • can't you just assign screen.peoplePickerDelegate = self; instead of using this scr?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文