Back button in the Detail view - ios

I'm struggling with "Master-Detail" concept and almost everything works as expected except one little(but important) nuance. What should I change on the storyboard to have Back button on Detail view(the right corner at the bottom on the screenshot)?
Thanks in advance.

This is an older question, but I just ran into the same thing. The issue is you do not need the navigation controller at the bottom right. Since that is a new navigation controller it will not have a back button, because it only contains one item in its stack.
Remove the bottom right navigation controller and just segue directly to the view controller and that will do it.
Additional tip... to remove the navigation controller and preserve the view, delete the link from the navigation controller to the view, and delete the segue links to the navigation controller. Then recreate the segues directly to your view controller.

So far don't get anything straight. If you want like just below screen then you have to hide your navigationItem backbutton in viewDidLoad like this
navigationItem.hidesBackButton = true
Then in storyboard you have add a toolbar and set it's item title 'Back'. You can also set image for it.
Then drag an action from this item and write this line inside that action
#IBAction func fbfdb(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
You may get an warning but you will get your desire action
Storyboard

Related

Adding a Back Button on A Table View Controller

I am interested in implementing a back button to segue to a previous view controller. I have tried to embed a navigation bar onto the the top of the table view controller but the issue is when I do segue back to the first view controller, by default, Xcode keeps the navigation bar with a back button to go back to the table view controller. Is there a simpler way to implement a segue to go back to the first VC without the navigation bar remaining?
I'm not too sure if this works, but embed your view controllers including the first one inside the navigation controller. That would make all your view controllers with navigation bar above.
On the main view controller (the one you do not want to have the navigation bar), add the line of code inside your viewDidLoad method.
Swift 3:
self.navigationController?.navigationBar.isHidden = true
I found an easy way. On your TableViewController, drag a UIview to the top of the view controller and itll let you insert the view. From there just add your back button
Just assign your "Back" UIBarButtonItem to this method and it should work.
#IBAction func backButtonPressed(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
}
Sounds like a few problems
1) How are you navigating from the first view controller? Is it with Show (Push) if not, you are replacing the first view controller in your stack.
2) Based on your problem, make sure your first view controller is not embedded in a navigation controller
3) As Dylan mentioned, you need to hook your back button to remove the current view controller to return to the first one
4) Extension of (3), how are you segueing back to the first view controller? If you are explicitly navigating to first view controller with your back button handler, it's not actually going back but rather forward and keep the navigation bar.

Back button does not show up in navigation controller

I have added a show segue from table cell in one view controller to another table view embedded in a navigation controller. When I click on the cell in the first view the segue works as expected and brings up the new view. However, the "Back" button (with the title of the original view) does not appear in the navigation bar.
I searched SO and found a number of such questions asked in the past (both for Swift and Objective-C). Most of them suggest that the first view needs a title for this to work. I do have a title. I even added one programmatically, just in case. That did not help. One of the answers suggested to add an identifier to the segue; that didn't help me either.
How else can I debug this issue?
It seems like the problem is that you are pushing into a totally new navigationController, remove it, and make segue dirrectly into the new view Detail itself, they have to be in the same navigationController to work
Verify you are not hiding backbutton in destination controller...
I had a left bar button item in storyboard removing the button, back button showed up.

Segue without the tab bar

I have a app that has a tab bar at the bottom.
I am trying to segue to a new view controller via a button that has the code:
#IBAction func moveOver(sender: UIButton) {
self.performSegueWithIdentifier("to-image-select", sender: sender)
}
This works and it segues to the new view, but the tab bar is still at the bottom. How do I make the tab bar not at the bottom? Is there some way of doing a segue that doesnt carry with it the tab bar?
EDIT 1
I do not want the tab bar, I would prefer to have a fully clean UI for this new view. I will have a back button that will take the user back to the previous page in the corner. I am looking into what modally segues are right now.
Will you need your tab bar further in your navigation ?
If yes, you might want to play with the hidden bool property to display it or not.
If no, you could set your segue as presentModally instead of a regular push.
Hope this helps, don't hesitate to provide more information about what your are trying to achieve
You do not have to use tabbar, you can use navigation controller, or present on top. I advise you to try a tutorial about storyboard before jumping in:
https://www.raywenderlich.com/113388/storyboards-tutorial-in-ios-9-part-1
Good luck (:

TabBar disappear after Push Segue

This is the current layout for my application. As you can see, I have a ViewController that is embedded in a TabBarViewController. You can see I have two tab bars in both of those bottom view controllers but only the first one shows up. In the second view controller after the push segue, the tab bar disappears. Why is this?
I added the properties for the First view controller and it is not set to hide the bottom bar during the segue so I am confused as to why it would disappear after the segue. Any ideas?
You'll need to wrap your tabBar's root viewControllers in a UINavigationController. So your UITabBarController would actually be pointed at the Navigation Controller. Then as you move around in that navigation controller, the tab bar will stay in place.
To fix this in your application, select your view controller in storyboard, then click "Editor" -> "Embed In" -> "Navigation Controller".
Here's a visual representation I just threw together for anyone else who comes across this problem. If you remove the "NavigationController" in the storyboard shown below, the tab will disappear when you click the button in "First View". With the navigation controller, you will maintain the tab bar. Hope this helps.
Try set self.tabBarController.tabBar.translucent = NO; in viewWillAppear
You could also try to dismiss the views by adding an outlet/action. For example, I experienced an issue where I had a TabBar view controller and needed to segue between 2 different views (ImageViews) on one of the tabs and as soon as I did a traditional segue, the whole tab bar disappeared. I had created the following "Back button" to clear the view:
#IBAction func backBtnPressed(_ sender: AnyObject) {
dismiss(animated: true, completion: nil)
}
Note: It is an important practice to clear views out as they will stack up overtime and will reduce the performance of your app.
Technical Info:
https://developer.apple.com/reference/uikit/uiviewcontroller/1621505-dismiss
Not sure if this helps but worth mentioning!

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

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.

Resources