简体   繁体   English

组合标签栏和导航栏控制器有问题

[英]Having problems with combined tab bar and navigation bar controllers

后退按钮问题

I am having a problem with the back button not going to the previous view controller despite me using segues (via push). 尽管我使用了segues(通过推送),但我的后退按钮没有进入上一个视图控制器的问题。 I think there is a problem since I saw this line on Apple's documentation saying 我认为有一个问题,因为我在Apple的文档中看到了这一行

"An app that uses a tab bar controller can also use navigation controllers in one or more tabs. When combining these two types of view controller in the same user interface, the tab bar controller always acts as the wrapper for the navigation controllers." “使用标签栏控制器的应用程序也可以在一个或多个选项卡中使用导航控制器。当在同一用户界面中组合这两种类型的视图控制器时,标签栏控制器始终充当导航控制器的包装器。”

But I want to be able to use a login screen which then moves onto a couple of screens before getting to a tab bar controller therefore not having the navigation bar wrapped in the tab bar controller. 但我希望能够使用登录屏幕,然后在进入标签栏控制器之前移动到几个屏幕上,因此没有将导航栏包裹在标签栏控制器中。 I know many popular apps use this, for example Instagram where you login then it shows the tab bar controller. 我知道许多流行的应用程序使用它,例如Instagram,你登录然后它显示标签栏控制器。

My current app layout is this; 我目前的应用布局是这样的;

Root navigation controller -> login -> meals (gif) -> tab controller (navigation controller for each tab (as per link) -> (My Rota/ My Meals/ Shopping List/ Item) 根导航控制器 - >登录 - >餐(gif) - >标签控制器(每个标签的导航控制器(根据链接) - >(我的罗塔/我的餐/购物清单/项目)

How to implement tab bar controller with navigation controller in right way 如何正确实现带导航控制器的标签栏控制器

It looks like it is behaving as expected, the back button is for your root navigation controller and when you use the 'back' button it pops your tab bar controller. 看起来它的行为符合预期,后退按钮用于根导航控制器,当您使用“后退”按钮时,它会弹出您的标签栏控制器。 I actually expected you to see two navigation bars, your root one and the one in the My Meals tab, unless you hide one. 我实际上希望你看到两个导航栏,你的根栏和我的用餐选项卡中的一个,除非你隐藏一个。

You could hide the root navigation bar when you push the tab bar, but you'll probably need a button in each tab's navigation bar which pops the tab bar from the root navigational controller. 您可以在按下选项卡栏时隐藏根导航栏,但是您可能需要在每个选项卡的导航栏中使用一个按钮,该按钮会从根导航控制器弹出选项卡栏。

Beyowulf's suggestion of presenting it as a modal is another option. Beyowulf将其作为模态提出的建议是另一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM