Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reached while popover is still visible

-(void)showsearch:(id)sender
{
    SearchViewController *searchview =[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];

    settingpopoverController = [[[UIPopoverController alloc] 
                                    initWithContentViewController:searchview] autorelease];               
    [searchview release];
    [settingpopoverController presentPopoverFromBarButtonItem:sender 
                                    permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


}

When I click on button, the app is crash and I got [UIPopoverController dealloc] reached while popover is still visible. message.

like image 678
saturngod Avatar asked Oct 24 '10 16:10

saturngod


2 Answers

There are some good discussions on this topic here:

Retain/release pattern for UIPopoverController, UIActionSheet, and modal view controllers?

UIPopoverController and memory management

The gist of it is you need to:

  • assign your autoreleased popover to a retain property
  • set the property to nil in your view's dealloc
  • as well as setting it to nil in the popoverControllerDidDismissPopover.
like image 191
Chris Avatar answered Oct 12 '22 22:10

Chris


think autorelease is incorrect, here is a tutorial

http://www.jannisnikoy.nl/index.php/2010/04/ipad-tutorial-creating-a-popoverviewcontroller

like image 21
Aaron Saunders Avatar answered Oct 12 '22 22:10

Aaron Saunders