Tab Bar Controller / Segue Issue

大城市里の小女人 提交于 2019-12-11 20:50:15

问题


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 -

  • Add Round View -


回答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.



来源:https://stackoverflow.com/questions/18776197/tab-bar-controller-segue-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!