Data disappears when switching between view controllers - ios

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];
}

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?

Swift Trouble with using the Navigation Controller

I am trying to add a Back button onto my table view controller (far right VC in the picture). I embeded a Navigation Controller and added a Back Item on the navigation bar with a segue to my second VC. However when I run the code, after I press back on the TableVC, it goes to a blank screen with the Back button still at the top. I want to be able to have the second VC screen when the back button is clicked, but I think there is some funky thing the navigation bar does. I was wondering if there was a way around this.
Ok so I'm pretty sure your problem is your embedding the wrong controller in the nav controller. You want to embed the second view controller in your picture into the nav controller, and then have your last one segue from that view controller.
Also, with a nav controller you don't need to add a nav bar or the back button. The embedded controllers will have these by default.
Embedding controllers is kinda confusing at first so its a good idea to take a look at some additional docs.
Here's a good tutorial that I used when starting out: Tutorial

Transition of a view controller embedded in a navigation controller

I have a problem with a transition. I am modifying this project https://github.com/xxxAIRINxxx/MusicPlayerTransition in order to have the transition from the right instead of the bottom. This part is fine. My transition comes from the right.
My problem is that I'm embedding the presented modal view controller into a Navigation Controller. I do this so I can use the "pushViewController" function when I click on a cell of my modal view controller.
My hierarchy is as follow. I have a dashboard. From the right, I drag a TableViewController X. If I drag back in the opposite direction, I come back to my dashboard. Fine. Now, If I tap a cell, it pushes a new ViewController Y.
Now, if I am in my new ViewController Y and that I drag back, I come back directly on my dashboard instead of going back to my TableViewController X, as a natural navigation controller should behave.
I did a small project on github that does only that, so you can easily see my entire code.
https://github.com/magohamote/NavigationControllerTransition.git
I understand why it behaves like this, but I would like to know how I can override the transition set on the navigation controller in order to have the normal behaviour of my navigation controller once it is presented.
Another problem I have not been able to solve. On the project I used as a starter (the one from xxxAIRINxxx) the transition is perfectly smooth. On mine, the first time I trigger the transition, it blinks and get stuck. Once I did it once, it is smooth the next time I drag my view. But the first time is always awful. I don't know why either :(
Thank you a lot for your help!

Dismissing a ViewController does not get to desired Controller

I am terrible at understanding work with interface builder, so (probably dumb) question comes.
I have created sliding view controller. When I click a cell, I want this controller slide back as it was. I used [self dismissViewControllerAnimated:YES completion:NULL];.
It used to dismiss table view controller (when I did not use Sliding). However, not it throws me not to previous controller, but to login page (initial controller). Have a look at the picture.
Hope this provides enough information. Sorry if it is not enough, as I am really bad with interface builder. I will add anything needed as requested. Thank you.
EDIT:
I have also tried to drag (holding ctrl) from sliding controller and chose ECSlidingSegue. In such case there is nothing going on.
Normal behavior of modal is when dismissed it shows its Parent Controller, in your case its I guess LoginViewController, form where you must have presented the TableViewController as modal.
However, if you wish to show a different controller other than the Parent, you can choose to push a new controller when come from TableViewController, or, you can achieve modal appearance with simple push of navigation controller, and I guess this would be easier and correct in your case.
So instead of presenting the TableViewController as modal, push it with Modal animation, and on selection of cell InboxViewController will be pushed.
There are few changes you need to do.
Create a Custom Segue from LoginController to TableViewController.
Create a push segue from TableViewController to InboxViewController.
I hope it helps.
Cheers.

The TabBarItem disappear when I push in other view

I have a TabBarApplication with four views in the main TabBarItem. The problem comes when I go to any of these views and click in any button to go to another view and when I go back by a button linked to the main view, the TabBarItem of the app disappear!!
For example, one view of the app is a tableView in which each element of the list is linked to his external view and it has a back button that should return to the tableView. All the segues are by modal, not push because push segue crash the application and by modal it runs correctly but the problem comes when I returned by clicking the back button of the NavigationItem in the header of the view to his main view and the TabBarItem of the app is not there, is empty.
Each tab should have the view controller set to a navigation controller, with the view controller you want set as the root view controller of the navigation controller. Now you can use push segues and the standard back button that will be added for you. This will bypass the issue (and work much better for you and users).
You current issue is likely related to not really ever going back. Instead, just always presenting new modal view controllers which replace any existing content on screen.

Resources