The best way that I can describe it is through and image, so i drew it out HERE. So, what happens is that in my table view, I press a button to add/edit information. When i am done, I press "Finish" at the bottom, which performs a simple segue back to the table view.
The Problem: Once back in the table view, the "back" button will now take me to the edit info page(which I just left) rather than the VC that came before it.
Is there any way to remove the Add/Edit info VC so that when I press "+" and "Finish" The back button will ignore the Add/Edit page?
Thank you for your help.
EDIT: . As you can see, when you press a button on the Table VC (lefT) it will take you to the right VC. Then, when you press finish at the bottom, it will perform a segue(no code, just a control-drag segue). The problem is still that the text message VC's back button will now direct back to the right VC, rather than the one preceding it (left)
I suppose you have a UITableView inside a UINavigationController since you have a back button, so:
User Tap Edit button: Push EditViewController in your UINavigationController
User Tap Finish from EditViewController: Save data, pop manually EditViewController and call reloadData of your UITableView
You would have to embed your complete sequence of view controllers in the navigation controller. This would maintain a stack of all the views that you would segue to. It will also give you a bcak button to go back to previous view. Alternatively, you can call the method popViewController() on navigation controller object to programmatically go to previous view. I hope that helps.
Related
I just started with Xcode and Swift.
I try to build my first little App for iOS. But now I have the problem, that I don't know how to implement a the back button, so that i come back to the view before.
My Storyboard look like this:
When I open the A-Z view, I want to display the Back Arrow, which turn me back to the Item 2 view.
To open the A - Z view I connect the button "Medikamente A - Z" with the Navigation Controller.
When using storyboards the back button is usually implemented with unwind segue.
I usually like to follow raywenderlich toturials on UI related topics, like this - http://www.raywenderlich.com/113394/storyboards-tutorial-in-ios-9-part-2
It include a detailed example of how to implement back button in storyboards. Quoting from it -
Storyboards provide the ability to ‘go back’ with something called an unwind segue, which you’ll implement next.
There are three main steps:
1. Create an object for the user to select, usually a button.
2. Create an unwind method in the controller that you want to return to.
3. Hook up the method and the object in the storyboard.
When using UINavigationController, whenever you push to a new ViewController the back button will automatically appear, so you can jump back to the previous View Controller.
So it's works like:
UIViewController -> UIViewController -> UIViewController
A back button will appear on the last 2 so you can pop back the the previous ViewController.
You don't have to do any additional coding for the back button to appear, it'll do it on its own. I hope this clears it up. Let me know if you have any questions.
To implement a back button, your root view controller has to be a Navigation Controller.
The first view controller becomes the navigation root of the navigation controller.
If you want to present another view controller, you select a "Show Detail" relationship as the action for the button which should show the view controller. To do this, Ctrl-click and drag from the button to the destination view controller and select "Show Detail".
I had the same problem, even when on the storyboard the back button was visible at design time.
I deleted the segue, and recreated it with "Show" instead of "Show detail". Changing the segue to "Show" had no effect. I think this is a bug, so if you miss that back button delete and recreate the segue.
I want to pop from childviewContoller to parentviewController in storyboard with out write any code in file with the help segue.
Thank You in Advance.
I would suggest having a button on your child view (potentially in a nav bar or anywhere else on the page). I your storyboard, control drag from the button on the child view, to the parent view. In the pop up, choose your action segue (standard slide in slide out would be the Show segue).
If you choose present modally as your segue, then you can change the Transition on the left to not animate. This give the segue a blunt but removal feel for the child segue.
Hope this helped
I know that a push segue automatically adds a back button so that the presentee can return to the presenter on click. What I want is for the back button to be available on the first UIViewController of the NavigationController (basically the only view controller in the chain that does not have a back button). How do I force add the back button?
I cannot simply add a custom image because I want the exact same chevron that comes with the iOS back button.
The easiest (yet hackish) way to achieve this is probably adding a dummy view controller in the stack before the actual first one, so you will get a proper back button. Use dummy's backBarButtonItem to customize the button title if you need, and -viewWillAppear: to respond to the button being tapped.
What I want is for the back button to be available on the first UIViewController .... How do I force add the back button
This whole thinking and logic is wrong. This is not how iOS UINavigationControllers work. You have a starting page (mainViewController) in a UINavigationControllers and from there you "move on" to something else. But you always come back to the main view controller. Just think about it, if you put a back button on the main view controller, where will the user go back to?
If you have a situation like this.
SomeViewController --> UINavigationController --> MainViewController
Once user is on SomeViewController and you take him to MainViewController which is part of UINavigationController then back button makes sense.
Just a FYI - you can easily drag and drop a UIBarButtonItem to any UINavigationController in Xcode and call it "Back". You will have to then connect that back button to another view controller.
Maybe it doesn't make sense but why can't you add a custom image? If all you want is "Back" chevron, can't you take a screenshot of this button and then put this image on your custom UIBarButtonItem?
Let's say we've got a few UIViewControllers on the stack of our UINavigationController
How can I define the UIViewController (instead of the previous one) the back button should pop to? (so basically pop two or more instead of one)
Maybe I want the back button to pop back to the root view controller, or just 2 view controllers before.
I know I could create a custom left bar button, but that looses the nice leftwards arrow in the button. And I don't want to use a png graphic to get that arrow back.
Edit:
I want to know how to pop to a certain UIViewController when pressing the back button in the navigation bar. I know how to pop to a certain controller, but not how to have the back button do it.
When you are pushing the viewControllers push all the ones that you may want to go back to and then use popToViewController:animated: to go back to the one that you want. Or use popToRootViewControllerAnimated: to go back all the way to the rootViewController.
Here is my current problem. I have a UIViewController setup with its data and everything on a small sized view controller. What I am trying to see is if it is possible to connect that to a separate view controller. For example I have a view controller that has a user click a button. Upon pressing the button the UIPicker ViewController would pop up from the bottom and I could go from there. I know how to enable this if the picker is on the same view controller. However, I have no idea how to if its on its own ViewController. Any ideas?
One way to do this would be to put the picker view on the same view controller and make it hidden, and, when they press the button, unhide it or load the other view controller when they press the button; this will display the other view controller, not what's on the current one.