Tab Bar Controller / Segue Issue
Asked Answered
D

1

0

I am working with 4 views using a Tab Bar. The first view has a tableview of rounds of golf. The second view allows the user to enter data for a new round. I have a button on the "Add Round" view that saves the inputted data to Core Data. When the user saves the round I want the view to segue back to the "home screen" where the rounds are displayed. I created a segue called "SavetoHomeSegue" in storyboard.

This is the code I use to switch between the views

[self performSegueWithIdentifier:@"SavetoHomeSegue" sender:self];
[self.tabBarController setSelectedIndex:0];

Here is my issue: When I switch back to the "Home Screen" the tableview now appears for the first tab AND the second tab. Also, it doesn't seem like the "Add Round" view was properly unloaded as I was previously having to manually clear the data inputs in the textfields. How do I transition from one tab to another and properly unload the views? I have posted my views below:

  • Home Screen View -

Home Scree View

  • Add Round View -

enter image description here

Deice answered 13/9, 2013 at 0:7 Comment(0)
M
1

You definitely shouldn't be segueing between tab bar vc's. Just save the data and refresh the other view on viewWillAppear. Call setSelectedViewController when necessary, but never segue between tab bar vc's.

Mesarch answered 13/9, 2013 at 8:2 Comment(1)
OK I will try that. I am obviously saving the data, but how do I get the "Add Round" view to add a new instance when I want to go back to it? I have had trouble where it crashes because it is trying to save the same instance to Core Data.Deice

© 2022 - 2024 — McMap. All rights reserved.