简体   繁体   English

UIPopoverPresentation和UIPopover关闭会导致崩溃

[英]UIPopoverPresentation and UIPopover dismissing causes crash

I have been working on app for months without any popover issues. 我在应用程序上工作了几个月,没有任何弹出窗口问题。 All of a sudden today popovers have gone to hell. 突然之间,今天的弹出窗口已经变得地狱了。

I have tried this a few different ways and no matter when I dismiss the popover by pressing a button in the popover OR tapping outside of the popover the app crashes. 我已经尝试了几种不同的方法,无论我是通过按弹出式窗口中的按钮还是点击弹出式窗口外的应用程序崩溃来关闭弹出式窗口的。

Using Instruments, I can see there is a zombie reference that only happens after the popover has been dismissed: 使用Instruments,我可以看到有一个僵尸引用仅在弹出窗口被消除后才会发生:

*** -[UITransitionView willRemoveSubview:]: message sent to deallocated instance 0x7f9985bcd980

So I have logged that stack and there isn't much help as the whole stack has to do with UIKit and built in animations, etc. 因此,我已经记录了该堆栈,并且没有太多帮助,因为整个堆栈与UIKit和内置动画等有关。

Using standard UIPopovers 使用标准的UIPopovers

self.popover = [[UIPopoverController alloc] initWithContentViewController:self.navVC];
self.popover.backgroundColor = [UIColor accentColor];
self.popover.delegate =self;
[self.seatingChartPopover presentPopoverFromRect:CGRectMake(x,y, 1, 1)
                                          inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Or use the new UIPopoverPresentationController method in ios8 或者在ios8中使用新的UIPopoverPresentationController方法

self.navVC.modalPresentationStyle = UIModalPresentationPopover;

UIPopoverPresentationController* popover = self.navVC.popoverPresentationController;
self.navVC.preferredContentSize = [self.childVC preferredContentSize];
popover.sourceView = self.view;
popover.sourceRect = CGRectMake(x,y, 1, 1);
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:self.seatingChartNavController animated:YES completion:nil];

I have made sure that all of the view controllers involved have a strong reference. 我确保所涉及的所有视图控制器都有强大的参考。

As I mentioned, I have not changed the the code that presents this popover in months and it's been working fine until today. 正如我提到的,我几个月来都没有更改显示此弹出窗口的代码,并且直到今天一直工作良好。 I have spent hours debugging this to no avail. 我已经花了几个小时调试它,但无济于事。

Also, If I just present self.navVC as a normal modal view, the view displays fine and dismisses fine. 另外,如果我只是将self.navVC呈现为普通模式视图,则该视图显示正常,并且关闭。 It's only when it's set as a popover that it fails 只有当它设置为弹出窗口时,它才会失败

Thanks in advance for any help. 在此先感谢您的帮助。

I'm ashamed to admit that I accidentally put a dealloc method in one of my UIView Categories. 我很ham愧地承认我不小心在我的UIView类别之一中放入了dealloc方法。

I am surprised this didn't bring up any sort of compiler warning, but after removing that there hasn't been any more bizarre crashing. 我很惊讶,这没有引起任何编译器警告,但是在删除之后,再也没有奇怪的崩溃了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM