Swift/XCode 6.4: add back button to navigation controller in navigation bar - ios

In my app I have this storyboard:
and I would like to add a back button from the second table view back to the first. So I inserted a Navigation controller in order to have a navigation bar in the second table view ad I have created a segue with its identifier from the second table view to the first. But then how can I add a back button? I have tried to drag a button from the library into the navigation controller but it won't let me do it...I had already done this but in this moment I can't remember how.
Please can you help me?

In above image you shared you are making your tableview controller as root view controller.You have to kept your navigation controller on root. As you can see in attached image and you don't have to make back button manually as navigation controller has its own default back button.

This example is right how to make storyboard.Try it
self.navigationController?.navigationBar.hidden = false
In setting of UINavigationController set up like on screenshot

If you're using a navigation controller and its default navigation bar, you don't add an explicit back button--the navigation bar does it for you. You can add a UINavigationItem to your view controller, on which you set a title, back button title, etc.

Related

Why is the navigation bar not appearing in the Simulator?

In my application that I am building, I set up a navigation controller to control navigation through the app. I created a Root View Controller.
I linked that Root View Controller to another View Controller using a show segue. Now the View Controller displays the navigation bar with the Large Titles turned off in the storyboard.
Even though it is showing up in the storyboard when I click the plus button, the navigation bar is not showing up in the Simulator. Does anybody know why?
Here is the complete Storyboard (Navigation Controller on the left - Root View Controller in the middle - Add View Controller on the right).
If someone could help me with this that would be amazing. Thank you.
You can retrace the steps and see where it went wrong:
1: Create a new single page app. Remove the VC and add TableVC. Set as root VC.
2: Select TableVC, Editor -> Embed in navigation controller.
3: Add tab bar item to the added navigation bar of the TableVC.
4: Create another VC and control drag from tab bar item to the VC (a push segue).
picture
Hi!Have you linked the Storyboard with ViewController like picture?That could be one reason.

Navigation bar missing in storyboard with show segue in Xcode 8

Why can't I see the navigation item under my second View Controller? My setup is as follows: I have a view controller embedded in a navigation controller. This view controller is linked to a second view controller with a "Show" segue. I can select & edit the navigation bar for the first view controller, but cannot see it in the element list for the second view controller. I also cannot edit it in the second view controller (i.e. add a button). How can I fix this?
First, drag a navigation item under your second view controller:
Then, you have it to edit:
How can you link the firstViewController and secondViewController? I try to link and I only can link the firstViewController and secondViewController in there.
But, this link is error, I set the different color for two viewController, the secondViewController cannot display.
So, you lost Navigation Bar? Select the View Controller you want to add and click on Status Bar / Top Bar dropdown list in Attributes
Inspector.
This is a known bug on Xcode, you can manually drag a Navigation Bar to your Second ViewController.

iOS Navigation Controller doesnt add navigation bar

My situation: http://i.stack.imgur.com/KTlVu.png
I have two views right now. From the second view, I want to have a back button that goes back to the initial view. I added a navigation controller and made it the initial view, and the navigation bar appeared for the first view(PlusCalendar). However, I don't know how to add a navigation bar for the second view(AddEventControllerVC) and add a back button that makes it go back to PlusCalendarView. I have looked at several tutorials and none of them surprisingly dealt with this problem. I am also looking at Apple's class reference and I am not sure if I have to initialize the navigation bar again from the second view controller. My questions are..
How come a navigation bar is not automatically added to all of my views?
For the second view, why does the navigation bar seem to be placed at the bottom?
How do I add a navigation bar on top of the second view, and add a "back" button?
The navigation bar was supposed to add the back button automatically. The problem was that the sigue between my first view and second view was set as a "modal popover." When I changed it to a "push" the back button appeared rightfully.
It seems that in model pop, the navigation bar is not record the view controller in its stack. So it cannot known the back track.In your case ,you should custom your navigation items in the second view controller. You can look this example: custom navigation bar

Using UITableViewController in a navigation bar

I'm new to iOS, but I know the basis. I want to host 3 UITableViewController in a UITabBarController using the storyboard.
I dragged a UITableViewController from the object list(?) and control dragged creating a seguel. Now the tab shows successfully the table view controller.
The issue is the rows are taking the space of the status bar. So I want a navigation bar(?) there, with a title. Since I'm new to iOS I don't know the following:
Given the fact that UITabBarController is the first controller ever, the hosted UITableViewController should not have a back button, obviously. So is it correct to use a navigation bar to display a title (and possible add/edit buttons)
If so, I tried dragging the Navigation Bar but it doesn't work.
What am I missing or doing wrong?
hope this helps
actually it is done for another answer. but it will be handy to u too
You will want to add in 3 UINavigationControllers. Have each tab in the tab bar controller segue to a different navigation controller. Then set the root view controller for each navigation controller to one of the table view controllers.

Tab bar disappears when trying to go back from new view

I am very new to Xcode and have encountered an issue with my app. I am trying to create a tab bar app. On one of the tabs I have a button that brings the user to a different ViewController. I want to have it so the user can select a button that would return them to the tab that had the button. I tried to set up an action from the button to the previous view (the tabbed screen), however the tab bar disappears. I hope this is makes sense.
Here is a link to a screenshot...
Easiest way to do this is to place a UINavigationController as the root view controller of the TabBarController. You can do this in storyboard by simply ctrl+dragging from the tabbar controller to the navigation controller and adding it as a relationship.
Here's an example using storyboards:
The next step is to set the third controller (in this case the table view controller) to your player view controller class.
Then, you can use the default back button and animation that comes with the navigation controller. If you prefer to hide the navigation bar at the top of the screen, then you can use your custom back button to call
[self.navigationController popViewControllerAnimated:YES];
You can also choose custom animations / segues, etc. but using a navigation controller to help you navigate screens is probably the simplest approach.

Resources