标签栏控制器/Segue问题 [英] Tab Bar Controller / Segue Issue

查看:108
本文介绍了标签栏控制器/Segue问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标签栏处理4个视图.第一个视图具有高尔夫球场的桌面视图.第二个视图允许用户输入新回合的数据.我在添加回合"视图上有一个按钮,可将输入的数据保存到Core Data.当用户保存回合时,我希望视图回到显示回合的主屏幕".我在情节提要中创建了一个名为"SavetoHomeSegue"的segue.

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

这是我的问题:当我切换回主屏幕"时,第一个选项卡和第二个选项卡的表格视图现在出现.另外,似乎"Add Round"视图似乎没有正确卸载,因为我以前不得不手动清除文本字段中的数据输入.如何从一个选项卡过渡到另一个选项卡并正确卸载视图?我在下面发表了自己的观点:

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:

  • 主屏幕视图-

  • 添加圆形视图-

推荐答案

您绝对不应该在标签栏vc之间选择.只需保存数据并刷新viewWillAppear上的其他视图即可.必要时调用setSelectedViewController,但不要在标签栏vc之间进行选择.

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.

这篇关于标签栏控制器/Segue问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆