Adding buttons to navigation controllers - ios

I am working in a swift 3 xcode 8 project, and I have an issue.
I have some view controllers.
In the first one I've inserted a navigation controller, which gives me the "back" button when I am in another view controller. So I can go on and back to the first viewcontroller.
The thing is, lets say, when I am in the third view controller I'd like to insert a button, but appearing just in this viewcontroller in the navigation controller.
I've tried adding a bar button item but it doesnt work because the navigation controller only appears, in the storyboard, in my first viewcontroller.
So how can I add buttons to the navigation controller, in another viewcontrollerS?

So how can I add buttons to the navigation controller, in another viewcontrollerS
Drag a Navigation Item into your third view controller. Now you can add bar button items to that.

Related

Pop view segue in Xcode

I have 2 UIViewControllers with their own navigation bars, but they're not embedded in a Navigation Controller. I want the bar button item of the first view to push the second view, and a bar button on the second view to pop the view, showing the first view underneath.
I've added a show segue from the first view to the second one in my storyboard but I can't find a pop segue when I try add a segue between the second view's bar button back to the first view. Here's what my storyboard looks like:
How would I make the back button on the second view pop itself to show the first view?

tab bar disppears in view from another controller ios

I have two controllers . A HomeVC and a UITabBar VC with 5 tabs. Each Tab has a view associated with it added in storyboard. Default landing page for the application is the view related to first tab. In each of the five tab views , there is a button named "menu" which takes me to the view related to HomeVC. Now, the problem is , when I press menu button and go to HomeVC's view, the tab bar does not appear. Is there a way to retain the tab bar in my Home VC's view with no tab selected?
You just have to embed your UITabBar ViewController in a Navigation Controller.

How to create a UIView with NavigationBar and TabBar

I would like to introduce in my app a View that will contains both navigation bar and a tab bar at the bottom. View contains a Table View with multiple entries and once user tap on a cell a push segue takes him to another view with details regarding the cell he has previously tapped. If he decides, user can go back to parent view by tapping on 'Back' button of the navigation bar on top. In addition to this, I would like my view to have a tab bar at the bottom with extra tools for the user. So, if he decides to check the 'Creator' of the app, he can by simply tap on 'Creator' TabBarItem at the bottom.
I would like to ask you what is the best way to achieve the above. I have already tried to use UITabBarController combined with UINavigationController. Didn't achieve what I was looking for because I would like the view with the table on it to be independent from the TabBarController and NOT a part of it (by part I mean by accessible through tabs).
Do you believe a UINavigationController view with UITabBarView would be a better choice?
UPDATE
What I mean by, "independent from the TabBarController and NOT a part of it":
Once the app loaded, I would like to see my main view (with table) contains Navigation Bar on top and Tab Bar at the bottom. However, I don't want to see the first tab of the Tab Bar selected because my main view will not be accessible through tabs of the Tab Bar but through Navigation Bar. If, for example, I am in Main view and tap on 1st tap, I would like to move to another view that will contains some other info.
Option 1:-
Create a tab bar Controller and on that TabbarController assign your navigation Views.
say nav1 with tab1 , nav2 with tab2...
Option 2:-
Create a Navigation View Controller and than add the tabbarcontroller on that navigationView Controller by using addSubView.
So when the user clicks on a row in a table u will go to a different View which doesn't have the TabbarController and when the user comes back he will again see the TabbarController.
This is what I will do:
First I will subclass UITabbarController and create for example ParentTabBarController. This controller will contain all the tabs necessary and what they will do if they are clicked so on.
Next for each viewcontroller I create, I will subclass from this ParentTabBarController so that the tabs are already in. You can add additional functionality or override it depending on your situation.
In your appdelegate pass in a navigation controller and every time push and dismiss the viewcontrollers you created in second step.
Hope this helps..

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.

(iOS) Why does second 'push' segue in navigation controller always crash?

I have a storyboard setup as a Tabbed Application with first view controller containing a
UITableView. The Protoype cell has a "push" segue to detail view which is embedded in a navigation controller. So far so good. The detail view pushes when a cell is selected and there is a navigation bar item to get back to the table view.
Now I run into trouble. The detail view has 2 buttons "Map" and "Ticket". If I create a new UIViewController, embed it in a navigation controller, and ctril-drag a 'push' segue from a button to the new view controller as before, the app crashes instantly with a SIGABRT when I click the button. If I don't embed in nav controller and use a 'modal' segue instead it doesn't crash but it seems a natural flow to continue with the 'horizontal slide' animation and the nav bar button back to the detail view.
Once I can stop that crashing I would like to connect the other button to it's own view controller with a UIMapView.
What am I doing wrong?
You don't need to embed a navigation controller in the detail view. You only need one at the top level. Take out the navigation controller in the detail view controller and just do a push from there to the next view.

Resources