Objective c ARC-取消分配图像库选择器?

Objective c ARC-取消分配图像库选择器?,objective-c,ios,xcode,uiimagepickercontroller,uipopovercontroller,Objective C,Ios,Xcode,Uiimagepickercontroller,Uipopovercontroller,我正在为iPad开发一个应用程序,我有点困惑,为什么ARC要出售一个如此声明的强大资产: @property (nonatomic, strong) UIPopoverController *imagePickerPopover; 我使用这个UIPopoverController来显示用户的图像库,因为如果你的建筑是iPad的,你必须这样做。有人经历过这种情况吗?它只给了我这个错误: *** Terminating app due to uncaught exception 'NSGeneri

我正在为iPad开发一个应用程序,我有点困惑,为什么ARC要出售一个如此声明的强大资产:

@property (nonatomic, strong) UIPopoverController *imagePickerPopover;
我使用这个UIPopoverController来显示用户的图像库,因为如果你的建筑是iPad的,你必须这样做。有人经历过这种情况吗?它只给了我这个错误:

*** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'
当我打开它的时候随机的。(例如,我可能能够在没有异常的情况下打开画廊一次,但不是两次或三次,而是第四次它抛出异常)这真的很奇怪

以下是我创建选择器的代码:

self.imagePickerPopover = [[UIPopoverController alloc] initWithContentViewController:picker];
[self.imagePickerPopover presentPopoverFromRect:aUIButton.frame inView:aUIButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

结果证明,我实际上是想让拾音器在打开时再次弹出。所以我只是使用isPopoverVisible属性来检查,如果不是,那么我创建并显示了popover。问题已修复。

因此,事实证明,我实际上是在试图使选择器在打开时再次弹出。所以我只是使用isPopoverVisible属性来检查,如果不是,那么我创建并显示了popover。问题已修复。

我们需要了解您是如何创建UIPopoverController的。您是否在用户每次点击控件时都运行该代码?您应该检查popover控制器是否已存在,然后仅在不存在时创建一个新的。我们需要了解您是如何创建UIPopover控制器的。您是否在用户每次点击控件时都运行该代码?您应该检查popover控制器是否已存在,然后仅在不存在的情况下创建一个新控制器。