Crash/SIGABRT when I try to present a UIPopoverCon

2019-02-12 15:42发布

Hi I am at my wits end with what I am doing wrong here. I am using ios5 and nothing crashes if I do not call presentPopoverFromBarButtonItem. Has anyone experienced anything similar? I checked the apple developer forums, google, stack overflow and couldn't find anything.

Running bt on gdb didn't reveal any hints either.

UIViewController *viewTwo;
viewTwo = [[ViewTwo alloc] initWithNibName:@"ViewTwo" bundle:nil];

UIPopoverController *popover;
popover = [[UIPopoverController alloc] initWithContentViewController:viewTwo];  

[popover presentPopoverFromRect:[theButton bounds] 
                         inView:theButton 
       permittedArrowDirections:UIPopoverArrowDirectionLeft 
                       animated:NO];

1条回答
叼着烟拽天下
2楼-- · 2019-02-12 16:33

I am assuming you are using ARC as I had this same issue. You have to hold on to the popup you have created otherwise its retain count will be decreased and it will be released when you get to the end of the methods scope.

So create a property and synthesise it until you no longer need it and remove it from screen, the set it to nil after it has been removed.

查看更多
登录 后发表回答