5

I have to show one popOver inside the left side of one splitController, I initialize the popOver whit an navigationController. But when i show the popOver my app crash.

Impostazioni *settings = [[Impostazioni alloc] initWithStyle:UITableViewStyleGrouped];
settings.title = NSLocalizedString(@"SETTINGS", nil);
settings.contentSizeForViewInPopover = kContentSizeOfPopOver;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:settings];
nav.navigationBar.tintColor = kTintColorNavigationBar;
nav.contentSizeForViewInPopover = kContentSizeOfPopOver;
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:nav];
[popOver presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

This is my code. Any ideas?

EDIT: Crash even if I set only a viewController instead of SplitController :/ And with a empty ViewController :/

Nicolò Ciraci
  • 678
  • 5
  • 23

2 Answers2

2

(Possibly duplicate of Error using UIPopoverController.)

In short, you need to retain the UIPopoverController somehow. Either by defining a property for it or by managing the ref count manually. With ARC, the latter is not an option, so you need to store the reference.

Community
  • 1
  • 1
Krumelur
  • 31,081
  • 7
  • 77
  • 119
0

I believe you need an instance variable to hold the popoverController. Otherwise after the method that contains the code that you showed finishes nothing will have retained your popover. Unlike when you add a subview to a view which the view would then retain the subview. The same thing does not take place for popovers.

agilityvision
  • 7,901
  • 2
  • 29
  • 28