Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crash/SIGABRT when I try to present a UIPopoverController

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];
like image 818
CPrescott Avatar asked Nov 11 '11 22:11

CPrescott


1 Answers

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.

like image 115
Scott Sherwood Avatar answered Nov 15 '22 18:11

Scott Sherwood