How to resize UINavigationController in a storyboard editor - ios

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.

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.

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.

Related

Why does embedding a View Controller in a Navigation Controller, then in a Tab Bar Controller attach the nav bar to the Tab Bar Controller?

Back when I first created the foundational layout for the app I'm currently working on in Storyboard, I did it in two steps:
Selected my View Controller and used Editor->Embed In->Navigation Controller.
Selected my View Controller again and used Editor->Embed In->Tab Bar Controller.
This was the resulting layout:
Question 1: Why do these steps create such an odd layout?
In this weird layout that seems to imply that the Navigation Controller is attached to the Tab Bar Controller as its parent, the only way I can get navigation items to display in the app (in the view controlled by the View Controller on the right) is by placing them in the nav bar of the Tab Bar Controller scene.
However, this creates various issues, including not being able to create an IBOutlet in my View Controller file for a custom view I drag into the title view slot in the Tab Bar Controller scene. Meanwhile, dragging anything into the navigation bar in the View Controller scene just makes it not appear in the app when it runs.
Question 2: How can I fix this layout so that I can control-drag from navigation items into my View Controller file? Or is everything actually correct, and I'm just trying to force something I shouldn't? (My intention here is to be able to set the custom title view's text in my View Controller code.)
Its obvious, if you want to embed MyViewController to NavigationController then you need to change your second step and need to embed NavigationController to Tab Bar Controller.
Selected MyViewController and used Editor->Embed In->Navigation Controller.
Selected NavigationController Embed with MyViewController and used Editor->Embed In->Tab Bar Controller.
It should look like this.
Note: You need to embed MyViewController to navigationController only if you want to perform push operation on this TabBarItem means with MyViewController other wise simply embed MyViewController to TabBarController no need to embed it with NavigationController.

Place content under iOS UITabBar

I'm trying to place my content under UITabBar. I created a Storyboard with controller in it and attached UIView to the bottom of content view of that controller(with constraints). After that, i created another Storyboard with UITabBarController and linked one of the tabs to the first Storyboard by storyboard reference. And the problem is that my UIView appearing always above the UITabBar while i want it to be under tab bar. Is there any way to achieve my goal?
Storyboard with UITabBarController
Storyboard with my view attached to the bottom of the content view
For using tabbarcontroller you should follow below scenario :
Drag tabbarcontroller to canvas (interfacebuilder), it will comes with two default view controllers. That means initially you have two tabs.
If you want more tab the drag another view controller to interface builder and then from tabbarviewcontroller ctrl + drag to that new View controller and from popup select relationship segue (viewController).
By this way you will able to new tab in tabbarcontroller and view in you tabs will not cover tabbar.

How to custom in storyboard my view controller's UINavigationItem that is instantiated by identifier and pushed onto navigation stack?

In storyboard I have UINavigationController with some controllers.
Within the last one I have a button Button. When I tap that button I instantiate another view controller from current storyboard:
But here I would like to custom my UINavigationItem with my custom UIBarButtonItems. How to do this here in storyboard?
Change Top Bar metrics for view controller:

Segue from the view controller embedded in a container view

My application has a UIViewController which is embedded in a UINavigationController. The UIViewController has a container view inside it. I connect this container view to a UITableViewController thereby embedding it in the container view. It's fine until now.
Now when I connect this UITableViewController to a new UIViewController using the push segue (we are still in the navigation view) in the storyboard, the size of the new UIViewController scene becomes same as that of the container view. I guess this is expected but is there some way not to make this happen. I want the remaining scenes to be in the normal size. Also, its working pretty fine and as expected when running in the simulator. The problem with the size is only pertained to the storyboard.
Just explaining my controller - view hierarchy here:
UINavigationController
-> UIViewController ( Initial View Controller )
-> Container View
-> UITableViewController ( Embed Segue )
-> UIViewController ( Push Segue )
Is there any way so that the last UIViewController and the remaining connected controller scenes are of normal sizes in the storyboard?
Here is one solution: Create a manual segue from your Initial View Controller to the desired destination. This will prevent the storyboard from getting confused and giving the destination the wrong size (and other inferred metrics). Unfortunately, because it is a manual view controller, you will have to perform the segue in code from your embedded view controller by doing something like this:
[self.parentViewController.parentViewController performSegueWithIdentifier:#"MySegue" sender:self];
As of Xcode 7 (I'm not sure if this applies to previous versions):
Select the view controller that is embedded inside your container view.
In the Attributes Selector, there are five drop downs at the top under Simulated Metrics.
Set Size to Master
Set Status Bar to Default
Set Top Bar to Translucent Navigation Bar
Now drag a UINavigationItem onto your view controller.
This will give you the correctly sized view controller and a navigation bar to edit.

Why nothing happen when connecting UITableViewCell to UInavigationcontroller

I have UITableView with Static cells. I control-drag from one of these static cells to another UINavigationcontroller and select "Push". I notice nothing happen, when I run the app and tap on the static cells.
However, when I do the same thing & choose "Modal" it works fine. Did I miss something?
You can only use a "Push" transition when segueing between view controllers within a parent UINavigationController.
Your Navigation Controller should be your app's initial view controller. Also when your table cell is tapped you'll want to segue to a View Controller (probably a custom UIViewController subclass), not a UINavigationController.
Make sure you have set your storyboard up with the following:
A UINavigationController - this should be set as the Initial View Controller for your app. Check that the checkbox "Is Initial View Controller" is checked in the Attributes inspector pane when the navigation controller is selected in the storyboard.
A UITableViewController - this should be set at your navigation controller's Root View Controller (there should be an arrow pointing from the nav controller to the tableview controller that looks like a segue but has a different icon in the middle)
Another View Controller - this is the view controller you want to segue to when clicking on your table cell, probably a customer UIVewController subclass you've created. Note that it should probably NOT be a navigation controller.

Resources