简体   繁体   English

如何隐藏导航栏+工具栏并更改滚动条上的tableView高度

[英]how to hide navigation bar + toolbar and change tableView height on scroll

I've got a view controller embedded in a navigation controller with a toolbar attached under it so it has this style: 我在导航控制器中嵌入了一个视图控制器,并在其下面附加了一个工具栏,因此它具有以下样式: 在此处输入图片说明

as you can see with my storyboard, i also have a container view with a tableviewcontroller inside: 如您在我的情节提要中所看到的,我也有一个带有tableviewcontroller的容器视图:

在此处输入图片说明

on scroll, i need to hide the navigation bar which I've been able to do. 在滚动时,我需要隐藏导航栏,该导航栏已经能够执行。 The problem is, I have to also hide the toolbar that is under the nav bar as well as expand the height of the table view so that when the nav bar and toolbar both disappear, the table view can use the extra space. 问题是,我还必须隐藏导航栏下方的工具栏,并扩展表格视图的高度,以便在导航栏和工具栏都消失时,表格视图可以使用额外的空间。

I don't have perfect answer but try to use below code in cellForRowAtIndexPath will help you.. 我没有完美的答案,但尝试在cellForRowAtIndexPath使用以下代码将对您有所帮助。

you did not mentioned weather your code is in objective C/ Swift. 您没有提到您的代码在目标C / Swift中。 I am providing you Both :: 我为你们都提供::

Obj-C 对象

[[self navigationController] setNavigationBarHidden:YES animated:YES];

Swift 迅速

self.navigationController().setNavigationBarHidden(true, animated: true)

For tabBar, If you want to hide tabBar with navigationBar use this thing.. 对于tabBar,如果要使用navigationBar隐藏tabBar,请使用此东西。 用这个

Or use this for tabBar hide > 或将其用于tabBar隐藏>

DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];    
[detailViewController release];

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

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