gpt4 book ai didi

ios - UIDocumentInteractionController & ARC : [UIPopoverController dealloc] reached while popover is still visible

转载 作者:行者123 更新时间:2023-12-01 16:41:30 26 4
gpt4 key购买 nike

之前已在此处讨论过此问题或类似问题,但我没有找到任何适合我的解决方案。

我正在使用以下代码显示 UIDocumentInteractionController在启用 ARC 的 iOS 7 项目上:

- (void) exportDoc{
// [...]
docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
docController.delegate = self;
[docController presentOpenInMenuFromBarButtonItem:mainMenuButton animated:YES];
}

首先,我不想创建一个包含 Controller 引用的属性,但正如许多人所说,没有替代品。它被定义为
@property (strong) UIDocumentInteractionController* docController;
exportDoc使用 NSOperationQueue 在主线程中运行.每当执行它时,我都会收到以下错误消息:

Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'



这就是回溯所说的:

(lldb) bt* thread #1: tid = 0x1c97d9, 0x000000019a23c1c0 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread',stop reason = breakpoint 2.1    frame #0: 0x000000019a23c1c0 libobjc.A.dylib`objc_exception_throw    frame #1: 0x000000018d982e90 CoreFoundation`+[NSException raise:format:] + 128    frame #2: 0x0000000190bc348c UIKit`-[UIPopoverController dealloc] + 96    frame #3: 0x0000000190e18fc8 UIKit`-[UIDocumentInteractionController dealloc] + 168    frame #4: 0x000000019a255474 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 524    frame #5: 0x000000018d881988 CoreFoundation`_CFAutoreleasePoolPop + 28    frame #6: 0x000000018e42cb18 Foundation`-[__NSOperationInternal _start:] + 892    frame #7: 0x000000018e4eea38 Foundation`__NSOQSchedule_f + 76    frame #8: 0x000000019a813fd4 libdispatch.dylib`_dispatch_client_callout + 16    frame #9: 0x000000019a8171dc libdispatch.dylib`_dispatch_main_queue_callback_4CF + 336    frame #10: 0x000000018d942c2c CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12    frame #11: 0x000000018d940f6c CoreFoundation`__CFRunLoopRun + 1452    frame #12: 0x000000018d881c20 CoreFoundation`CFRunLoopRunSpecific + 452    frame #13: 0x0000000193511c0c GraphicsServices`GSEventRunModal + 168    frame #14: 0x00000001909b2fdc UIKit`UIApplicationMain + 1156   * frame #15: 0x000000010000947c MyApplication`main(argc=1,argv=0x000000016fdfbc80) + 108 at main.m:16    frame #16: 0x000000019a82faa0 libdyld.dylib`start + 4


据我了解,自动释放池只是释放 Controller 。难道不应该像我一样使用强大的属性来防止这种情况吗?

您知道问题可能是什么以及我该如何解决吗?

[编辑]

我禁用了 ARC 并手动添加了 [docController retain]并让它工作。我想知道我的项目是否真的启用了 ARC 并尝试了以下预处理器代码
#if !__has_feature(objc_arc)
#error no arc
#endif

但不显示错误。

最佳答案

似乎您正在使用的 docController 是一个局部变量,而不是一个类级别的变量。当您使用局部变量时,它会被释放。您是否尝试使用该属性而不是 iVar,如下所示。

- (void) exportDoc{
// [...]
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
self.docController.delegate = self;
[self.docController presentOpenInMenuFromBarButtonItem:mainMenuButton animated:YES];
}

关于ios - UIDocumentInteractionController & ARC : [UIPopoverController dealloc] reached while popover is still visible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23893236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com