Search code examples
uiviewcontrollerinterface-builderuitoolbar

How to make UIViewController toolbar appear?


When placing a UIViewController on the storyboard it has a "built in" toolbar that I can add buttons to during design. My problem is that it does not appear at runtime. There is the property toolbarHidden but this did not work to control the visibility of the toolbar. How can I set it to be visible?


Solution

  • The "builtin" toolbar is in the "Simulated Metrics" section of the Attributes Inspector.

    These entities are available for design purposes only, they simulate the effect of widgets that may be imposed on the viewController due to external conditions.

    In the case of the simulated toolbar metric, this is showing you how the viewController would look if it were embedded in a UINavigationController who's toolbarHidden property is set to 'false'

    UIViewController does not have a toolbar property, which is why you cannot find a reference to it in the header file.