1

我有一个视图控制器通过条形按钮项打开一个“打开”对话框。

调用代码:

UIDocumentInteractionController *docInteraction = [[UIDocumentInteractionController alloc] init];
docInteraction.URL = location;
docInteraction.delegate = self;
if ([docInteraction presentOpenInMenuFromBarButtonItem:self.openInButton animated:YES])
    self.openInController = docInteraction;

解雇代码:

UIDocumentInteractionController *openIn = self.openInController;
if (openIn) {
    [openIn dismissMenuAnimated:animated];
    self.openInController = nil;
    popupsDismissed = YES;
}

关闭代码后的某个时间,应用程序崩溃并出现以下异常:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[A2DynamicUIPopoverControllerDelegate popoverController:animationCompleted:]: unrecognized selector sent to instance 0x1f82b4f0'

这是一个 BlocksKit 定义的接口,但在特定情况下我没有使用 BlocksKit 类。0x1f82b4f0 是一个<A2DynamicDelegate: 0x1f82b4f0; protocol = UIPopoverControllerDelegate>,但为什么 BlocksKit 会出现在这里是一个谜。有人可以给我一些有关如何解决异常的见解吗?

4

1 回答 1

0

BlocksKit 有点像红鲱鱼。解雇代码在UIDocumentInteractionController这里过早地解除分配:

    self.openInController = nil;

最早,释放应该在-documentInteractionControllerDidDismissOpenInMenu:委托回调方法之后发生。

于 2013-10-29T01:13:13.177 回答