简体   繁体   English

导航控制器干扰TabBar控制器

[英]Navigation Controller interfering with TabBar Controller

I have a menu, which is just a tableview on a tab. 我有一个菜单,它只是选项卡上的表格视图。 When you select one of the table cells it segues to a viewcontroller that is embedded in a navigation controller. 当您选择一个表格单元格时,它将选择到嵌入在导航控制器中的ViewController。 i have added a 'Done' button to this navigation controller and created a segue back to the menu. 我已经向此导航控制器添加了“完成”按钮,并创建了返回菜单的菜单。 however now the menu doesn't show the tabBar and it now shows a navigation bar with a 'Back" button on it. 但是,现在菜单不显示tabBar,而是显示带有“后退”按钮的导航栏。

This is the menu (part of tab bar) just a table view 这是菜单(标签栏的一部分),只是一个表格视图

在此处输入图片说明

This is the pages shown when clicking tableview cell 这是单击表格视图单元格时显示的页面

在此处输入图片说明

This is the menu again after clicking 'Done' 单击“完成”后再次是菜单

在此处输入图片说明

when clicking done i wanted it to go back to the menu as it was shown in the first screenshot. 单击完成后,我希望它返回到第一个屏幕截图中所示的菜单。 i was trying to use the interface builder for this but guess i could create a class and go back to the menu via code. 我试图为此使用界面生成器,但我想我可以创建一个类并通过代码返回菜单。

Any ideas how to fix this? 任何想法如何解决这一问题?

----- EDIT ----- -----编辑-----

This is support page without 'Done' button 这是没有“完成”按钮的支持页面

在此处输入图片说明

------ EDIT ----- ------编辑-----

this is the flow layout, sorry its messy working on small screen laptop atm 这是流程布局,很抱歉在小屏幕笔记本电脑atm上工作混乱

在此处输入图片说明

You should use the "Show (eg Push)" segue and not "Push". 您应该使用“显示(例如,推送)”提示,而不是“推送”。 This allows it to show itself correctly in the stack. 这样可以使其正确显示在堆栈中。

Using "Push" requires that the existing screen exists inside a navigation controller, which it doesn't on the first load. 使用“推送”要求现有屏幕存在于导航控制器内部,而不是在第一次加载时就存在。 By using "Push" it is moving the controller into a navigation controller stack which leaves you with the navigation bar after pressing done. 通过使用“推”,它会将控制器移动到导航控制器堆栈中,按完后,您将剩下导航栏。

By using the "Show (eg Push)" segue option, the system will chose to use a modal presentation or a navigation controller push based on your current view hierarchy. 通过使用“显示(例如,推送)” segue选项,系统将根据您当前的视图层次结构选择使用模式表示或导航控制器推送。

Show (eg Push): 显示(例如推送):

在此处输入图片说明

Note: if your view is shown using a Model presentation you need to use 注意:如果使用模型演示文稿显示视图,则需要使用

[self dismissViewControllerAnimated:YES completion:nil]; 

and not 并不是

[self.navigationController popViewControllerAnimated:YES]; 

You can do a quick check to choose the correct method: 您可以进行快速检查以选择正确的方法:

if (self.navigationController) {
    [self.navigationController popViewControllerAnimated:YES];
}
else {
    [self dismissViewControllerAnimated:YES completion:nil];
}

This will allow you to show the screen in multiple ways without having to do any additional checks 这将使您能够以多种方式显示屏幕,而无需进行任何其他检查

I just realised you did not have a Navigation bar on your Menu Tab. 我只是意识到您的“菜单”选项卡上没有导航栏。 All you need to do is embed in a navigation controller. 您需要做的就是将其嵌入导航控制器中。 Let me know if it does not work. 让我知道它是否无效。

在此处输入图片说明

override  func tableView(_ tableView: UITableView, didSelectRowAt
 indexPath: IndexPath){
    if(indexPath.row == THE_ROWNUMBER_OF_YOUR_SUPPORT_PAGE){
        let displaySupportPage = self.storyboard?.instantiateViewController(withIdentifier: "SuppportPage") as! ChooseSalonTVC
        self.navigationController?.pushViewController(displaySupportPage, animated: true)
    }

 }

在此处输入图片说明

Check "Hide Bottom Bar On Push" 选中“隐藏底推”

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

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