How to resize UINavigationController in a storyboa

2019-04-21 12:10发布

问题:

When I want resize an UIViewController in a storyboard editor window I do:

  • I put size to "freeForm" in the UIViewController attributes inspector
  • I select the view and resize her with the size inspector

after that, the uiViewController is resized in storyboard window.

Next, I select the view controller, click on: edit > embeded in> Navigation Controller and the problem is that navigation controller is in full size and not the same size that UIViewController. I don't find how resize this navigation controller.

回答1:

You don't resize a NavigationController - it is not a ViewController. It controls the navigation of ViewControllers. You specify an initial ViewController (the one you embedded into it will be the initial viewController by default). You then create segues into other ViewControllers.



回答2:

There's a trick to get around this limitation. Add a view controller to your storyboard and then add a Container View as a subview to it's view. Size that container view to the size you want the navigation controller (and it's children) and then control drag from the container controller to your navigation controller. You can then instantiate the navigation controller by identifier and the container view controller will be ignored.