推键后我的Tab栏控制器消失了 [英] My Tab bar controller disappears after a push segue

查看:109
本文介绍了推键后我的Tab栏控制器消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的应用程序的设置:

Here is the setup of my app:

导航-

-loginVC-如果登录有效,则将segue推送至-

-loginVC -if login is valid, pushes segue to-

    tab bar controller with 3 tabs:
      -in the first tab, is a profile display which modal pushes to a profile editor(not
       issue here)
      -second tab is a searchVC that pushes to a tableVC that shows results. This is  
       where the tab bar disappears
      -The third view is just a VC for updating the database this is linked to.

从字面上看,这就是情节提要上的工作方式,而且我已经确保了从searchVC到tableVC的选择是推送选择.

This is literally how it works on the storyboard, and I've made sure the segue from the searchVC to the tableVC, is a push segue.

如何防止标签栏控制器在第二个视图中消失.

How can I keep the tab bar controller from disappearing on this second view.

推荐答案

结构应为

loginViewController -->modal segue--> tabBarController
                                        |
                                        |
                                        |-->NavController->Item1ViewController
                                        |
                                        |-->NavController->Item2ViewController
                                        |
                                        |-->NavController->Item3ViewController

此刻,当您从项目2的第一个viewController推入时,第二个选项卡项上的推"将整个选项卡栏控制器推开.

At the moment, the 'push' on your second tab item pushes the whole tab bar controller out of the way when you push on from item 2's first viewController.

如果要在loginViewController上导航栏(为了保持一致性),请将其嵌入其自己的navigationController中,但请确保不要从此处推动:modal segue或与[self presentViewController:tabBarViewController animated:yes completion:nil]

If you want a nav bar on your loginViewController (for consistency), embed it in it's own navigationController but ensure you don't push on from there: modal segue or present with [self presentViewController:tabBarViewController animated:yes completion:nil]

每个选项卡栏项的导航控制器都是可选的(取决于您要执行的导航,显然您确实希望对项2进行导航)-但为了保持一致性,可能希望对每个项进行导航.

Each of the tab bar item's nav controller is optional (depends on what navigation you are after, clearly you do want one for item 2) - but you may want one for each item for consistency.

更新
@rdelmar建议将登录屏幕用作根视图控制器的这种方法(在其顶部以模式"方式呈现应用程序的其余部分)是对模式选择的滥用,并建议在第一个模式中以模式方式显示登录屏幕标签项.我理解这一点,并将对此进行更多的思考,但是同样,我也发现替代方法有些不舒服...选项卡项目在tabVC中应具有相同的权重-因此,使第一个项目呈现出整个应用程序所依赖的模式登录控制器感觉不像很好的程序流程.如果应用程序要求用户登录,那么以某种方式支持它的登录名不会出现任何问题.

update
@rdelmar suggests that this method of using a login screen as a root view controller - on top of which the rest of the app is 'modally' presented - is a misuse of the modal segue, and suggests modally presenting the login screen on the first tab item instead. I understand the point and will give it some more thought, but likewise I find that alternative a little uncomfortable... tab items should share equal weight in a tabVC - so making the first item present a modal login controller on which the whole app depends doesn't feel like good program flow. If an app requires the user being logged in, I don't see anything wrong with the login somehow underpinning it.

在这里的答案中,我对此有更完整的描述:(

I have a more fully described version of this in an answer here:(How to handle UINavigationControllers and UITabBarControllers iOS 6.1). This also has the advantage that if you offer a logout button from anywhere in your app, an unwind segue back to that first login screen - effectively un-presenting the entire logged-in app stack - will work nicely.

另一种解决方案-与@rdelmar的解决方案类似-如果不在选项卡栏控制器中,则从第一个viewController 模态显示登录屏幕.这可以在我前面提到的答案中起作用,因为登录后的第一个屏幕是navController嵌入的viewController.但是,退出注销并不是那么干净.

A different solution - which chimes with @rdelmar's - would be to present the login screen modally from the first viewController if that were not in a tab bar controller. This could have worked in my aforementioned answer as the first screen after login was a navController-embedded viewController. However the unwind-to-logout would not have been so clean.

最后,我怀疑这可能只是一个风格点,只要流程逻辑保持健壮,我们就不要太挂了.

In the end I suspect this is may be just a point of style that we shouldn't get too hung up about so long as flow logic remains robust.

这篇关于推键后我的Tab栏控制器消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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