Popping back quickly not possible in a navigation controller - ios

I have a navigation controller and it won't let me quickly pop back from a view controller onto a another view controller and to another view controller. There seems to be a delay (very small) until the back button is enabled and therefore, it requires me 2 taps to be able to navigate back one more time. Is there a way to get rid of this delay?
Thanks.
UPDATE: I am not asking for the way of popping up multiple view controllers at once. What I want is to pop one by one but it seems like for a very short period after i pop one view controller the new view controller does not register my gestures, so it wont let me tap on it to pop that new view controller as well manually. The problem just seems to be that there is a small delay until i am able to register any tap gestures onto the new view controller, it appears as it is something similar to the delayTouch or cancelsTouchInView of the gesture recognizer.

Related

dismiss a tabbed view controller from a seperate modaled to view controller

So, I have a tab bar view controller, however at some point I need to manually segue to a viewcontroller that is not attached to the tab-view controller. The segue works, but then it jumps back again to the previous view controller randomly after 1/2 a second to 3 seconds, not all the time, but often. Occasionally I see a message saying something along the lines of "cannot dismiss viewcontroller while another dismiss or presentation is already taking place" but I've double checked all my code and there are only three places that make the jump, none of which can be called simultaneously. What I need to know then, is how I go about dismissing the tab viewcontroller in the view did load method of the modaled to controller. Swift explanations are no good to me thanks. Also, not related to this question persay, but can anyone tell me what the sliding bar thing that looks like a UISlider and tracks the progress of a song is called?

Dismissing view controllers with no fixed order

I'd like to know the best way to handle view controllers when there are multiple ways for the user to navigate through an app. The problem is that the user might (for example) trigger a segue by selecting a table row, Then, from the presented view controller they might click a button in a custom toolbar to go somewhere else.
I'm pretty new at this, so while I understand using a segue to present a view controller, and then having to dismiss the presented view controller at some point, I'm less clear on how to manage things when a user has free reign to go wherever they want! I'm using container views to embed a header and a custom toolbar at the bottom of each view. Should I be using a container for each view controller as well?
If you are quite down the stack and you don‘t want to offer a back button for simplicity, then you go up the stack by calling dismiss and tell the delegate where you want to go until you reach the appropriate level which can move you up until you are where you wanted to go.
The alternative is to move up the delegate chain until you can move down again and from there call dismiss and then go down where you want to go.

Dismissing and presenting View Controllers - An Explanation?

Recently, I've been reading about the concepts behind dismissing and presenting View Controller. I've been able to pick up on the ideas of dismissing the previous View Controller from the destination View Controller but I can't find an answer to a few questions that have been on my mind for quite a bit.
Scenario 1: I have a login page and after the user enters their credentials, it performs a segue to another View Controller. Is it necessary to dismiss the login page afterwards or is there no reason to?
Scenario 2: I have two normal View Controllers (VC1 and VC2). If I perform a segue to VC2, will I need to dismiss VC1?
I'm mainly confused regarding the idea of when it is necessary to dismiss View Controllers and when it is not necessary to do so.
I'd appreciate it if anybody could help clear these questions up for me.
Scenario 1: After performing a segue, it switches between your view controllers [ automatically dismisses the current ViewController and presents a new one ].
So, there's no reason to dismiss the login page.
Scenario 2: No you don't need to dismiss VC1.
1) When you go from login controller to second controller you just need to present the second controller and no need to dismiss first because if you are using navigation controller as a part of your segue all the view controllers are arranged in form of a stack . So second comes on top and first goes below it.Now if you need to got from second to first you can either dismiss your controller or pop your controller.When you dismiss a controller it is not popped from stack instead just moves behind and let the first controller come on top and when you pop a controller it removes itself from stack as well.
2) Same goes for your second question no need to dismiss first when you go from first to second controller.
If there is a view controller which in most cases will be used only once (like login or settings etc.) — and especially if, after you’re done with it, it makes sense to return to the view controller you were on before — the best is to present it modally and dismiss it when you’re done. The rest of your view controllers stay in memory after the user can no longer see them, and this is expected behavior given the way Apple has created the methods for presenting and dismissing view controllers.
It is my understanding that in the Android world, this is not the case -- the default there is that when a new view controller is presented, the old one really does goes away.
As you know once user has signed in, log in screen not opens until user log out. So you should remove log in view controller from stack, it should not keep in memory. For this task, do not directly perform segue, you should change root view controller. There are lot of answers on stackoverflow for How to change root view controller?

iOS navigation best practice for adding items

I cannot find the answer to this although I have implemented this rather a few times already, but maybe the wrong way.
Say I have an App for iOS, it has a main screen, which goes to a list, that list has a < back (to main) and an add button. Now when I click < back, I go back to main as that's the pop() from the stack. No issues so far.
Now when I click the add button, that is added to the stack as well; when I click back on that screen I go back to the list which is fine.
The problem is; when I save the new item, I want to go to the detail screen, but I don't actually want to have the add screen on the stack anymore while it will be there. I want the < back button for the detail item pointing to the list.
I know how to do this, but what is actually the best to implement this with the navigation stack?
Well for adding elements the best practice is to present an ModalViewController.
In this way it is not added to the stack.
Update
Let's take as examples simple apps that apple provide with iOS, Contacts app. When you want to add a new contact a VC is presented.
You'll need to implement "Done" or "Save" button that will dismiss the modalViewController and if you want to take the user into detail screen you could post a notification or other mechanism on dismissViewController method's completion block that will push the detail page from the list. But be careful on animations if you dismiss the modal VC animated and push the detail page animated you could get some unexpected behaviour. My proposal is to dismiss the Modal VC animated and push the detail page without animation.
You can override UINavigationController's viewControllers property after you pushed detail view controller. Just get current viewControllers property array, iterate and find the one you don't want to see and remove it. Remember to set viewControllers array again.
https://developer.apple.com/library/ios/documentation/Uikit/reference/UINavigationController_Class/index.html#//apple_ref/occ/instp/UINavigationController/viewControllers

Data disappears when switching between view controllers

I am writing an iPhone application using the storyboards for an initial mockup. The problem I have right now is switching view controllers.
I have a table view controller and another view controller. All I want to do is use a back button to go back to the original screen, and I can do that, except the data disappears. The storyboard that I have is shown below.
I have the Back button going back to the original navigation controller. I have also had it going back to the Card view controller.
I have hard coded some example cells to just see how things look and they show up just fine when I run the simulation. When I click the back button though, it goes back to the All Cards screen and the cells that were there are now gone.
If I need to post some code just ask for what part would be helpful, I have done all of this through storyboards though.
I'm sure it's something stupid I've done, any point in the right direction would be greatly appreciated.
Basically: you pushed where you should have popped.
What you are seeing on the Storyboard does not exist yet. By segue-waying during runtime to a view controller it gets instantiated.
When you segue-wayed during runtime from the Add Card view controller "back" to the Card View Controller - here is what happened: instead of popping the navigation stack all the way back to the Card View Controller you already had, you just instantiated a new Card View Controller and pushed it onto the navigation stack. You could verify that by going all the way back to the original Card View Controller by tapping the back button several times.
What you could do to accomplish your task is this:
Instead of using the Storyboard for your back button use an IBAction in code:
- (IBAction)popToRoot:(id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}

Resources