ARC - 解除分配图像库选择器



我正在为 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 属性进行检查,如果不是,那么我创建并显示弹出框。问题已修复。

最新更新