Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is probably because you have no root view controller, or are otherwise fiddling with the navigation controller in ways it was not meant to be played with. This is how you ought to be setting up the popover:</p> <pre><code>MyCustomViewController *viewController = [[UIViewController alloc] initWithNibName:@"MyCustomViewController" bundle:nil]; //or storyboard or whatever UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController]; //you should have a root view controller before displaying the popover tintColor = [UIColor redColor]; UIPopoverController *tempPop = [[UIPopoverController alloc] initWithContentViewController:nav]; [tempPop presentPopoverFromBarButtonItem:mainButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:NO]; </code></pre> <p>There are a few very important things going on here:</p> <ul> <li>Your navigation controller should have a root view controller before you display it.</li> <li>This code is using a standard <code>UINavigationController</code> instance. According to the <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html">documentation</a>, you should not subclass <code>UINavigationController</code>, nor should you try and reinvent the wheel. Apple has created a complex and comprehensive framework, UIKit, that you can use to build amazing apps. If you try and step outside the box, you'll be creating an awful lot of work for yourself without any appreciable benefit.</li> <li>This is using the <code>tintColor</code> property of the <code>UINavigationBar</code> class. If the tint is insufficient for your UI, you can also set the background image manually (refer to the <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationBar_Class/Reference/UINavigationBar.html">docs</a>).</li> </ul> <p>If you want to make a popover with a navigation controller, use the built-in <code>UINavigationController</code> class. Don't subclass it and don't reinvent it. To customize the appearance of the <code>navigationBar</code>, use the <code>UI_APPEARANCE_SELECTOR</code> methods in the <code>UINavigationBar</code> class. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload