UIPopoverController dealloc getting called—ARC environment

后端 未结 2 1689
走了就别回头了
走了就别回头了 2021-02-12 14:43

While displaying a popover controller for a second time (after dismissing it and then re-displaying it), I get the following error:

Terminating app due to uncaug

相关标签:
2条回答
  • 2021-02-12 15:10

    If your popover is stored as strong reference, it can't be deallocated. The only possibility when it can be deallocated is in the situation when the object containing the strong reference (self in your example) is also deallocated.

    I think the important question is what are you doing with your views when the popover is visible.

    If you have already checked this, than it must be a framework bug.

    0 讨论(0)
  • 2021-02-12 15:13

    I have run into the same problem and fixed it by retaining the popover controller in a strong instance variable as suggested AND explicitly dismissing it before resetting the property with the new popover controller allocated in in the second run of the action. In your example, you should add something like this:

    - (IBAction)createNewScore:(id)sender {
        if (self.pc) {
             [self.pc dismissPopoverAnimated:YES];
        }
    
    0 讨论(0)
提交回复
热议问题