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:
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..
you did not mentioned weather your code is in objective 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..
Or use this for tabBar hide >
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];
[detailViewController release];
Related
https://drive.google.com/file/d/0B-LCl4SF8TXKUWVBMU9KZFEtYVU/view?usp=sharing (video link)
Refer to the title mentioned, I am having weird display issue when pushviewcontroller from UITabBarController to UIPageViewController.
I am having such views:
- UITabBarController
-- MoreViewController
push to
-AlertsPageViewController
with the following codes when I click "Alerts":
AlertsPageViewController *vc = [[UIStoryboard storyboardWithName:#"SBAlert" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:#"AlertsPageView"];
vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:vc animated:YES];
It leaves a big white space on the bottom of the screen with distorted tabbar at the bottom, until the "AlertsPageViewController" appear, only then it fill the gap below. When I click on "Back", the bottom bar also doesn't display probably. This behaviour only appear when I pushview to "UIPageViewController". If I push to normal "ViewController", it works correctly.
Tested on iOS9 and iOS10. How can I fix this?
Found out that other then using hidesBottomBarWhenPushed, another efficient way to hide the bottom bar is adding 1 line code
- (void) viewDidLoad
{
[self.tabBarController.tabBar setHidden:YES];
}
at the pushed view (AlertsPageViewController).
I'm learning IOS now, and working on Tab Bar Veiw Controller. I want to hide the tab bar on sub view, so I set 'Hides Bottom Bar On Push' true, it's working fine on second view. But if I set it true on Third View, the Tab Bar is not hidden.
How can I hide the tab bar when third view push?
I already try to find the result on line, but cannot find, please help me.
You can follow code below, hope can help you
DetailViewController *detailViewController = [[DetailViewController alloc] init];
detailViewController.hidesBottomBarWhenPushed = YES;
[[self navigationController] pushViewController:detailViewController animated:YES];
[detailViewController release];
I've created a storyboard based UITableViewController which is working and displaying data.
I now need to add a toolbar that will always be at the bottom of the screen. To do this I have added a toolbar button to my storyboard which has it positioned at the bottom of the screen.
I have added the following to my tableviewcontrollers viewWillAppear method
[self.navigationController setToolbarHidden:NO];
As described here
How to add a toolbar to the bottom of a UITableViewController in Storyboards?
However, I still get no toolbar...any ideas?
You want show toolbar in one view controller which placed in some navigation controller.
- (void)viewWillAppear:(BOOL)animated
{
//View will appear
[self.navigationController setToolbarHidden:NO animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated
{
//View will disappear
[self.navigationController setToolbarHidden:YES animated:YES];
}
I have a storyboard app that has a few view controller that need to get pushed on the navigation stack programmatically, instead of with segues. I'm using the following code to do it:
POCollectionViewController* vc = [self.storyboard instantiateViewControllerWithIdentifier:#"categoryView"];
POCategory* destination = (POCategory*)self.collections[indexPath.row];
[vc setShowingCollection:destination];
[self.navigationController pushViewController:vc animated:YES];
My problem is that when I use segues to push view controllers and I press the 'back' button, the scroll position is preserved, but when I use the above code and press the 'back' button, my previous view controller appears with the scroll bar at the top.
Is it re-instantiating a view controller that is supposed to be already on the navigation stack? How can I preserve the scroll position?
EDIT
Code for setShowingCollection:
-(void)setShowingCollection:(POCategory*)collection
{
self->showingCollection = collection;
self.title = collection.name;
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
self.HUD.delegate = self;
[self.HUD showWhileExecuting:#selector(buildDisplayItems) onTarget:self withObject:nil animated:YES];
}
The buildDisplayItems method fetches a bunch of the data from the server based on the showing collection's ID.
I think that you are not popping the controller correctly, your are not poping to the pushed controller, but popping to a newest controller. How you are doing the pop controller in your back button ?
you should do like this :
[self.navigationController popViewControllerAnimated:YES];
My immediate thought is if you must instantiate a new controller for every "segue" you will have to save the scroll position and when you reload the view cause the the uiscrollview to scroll.
Something like this saved in a property should do the trick:
CGRect scrolledRect = CGRectMake(scrollView.contentOffset.x, scrollView.contentOffset.y, scrollView.bounds.size.width, scrollView.bounds.size.height);
Then when you reload:
[scrollView scrollRectToVisible:scrolledRect animated:NO];
I'm trying to achieve something similar to user of this post:
Xcode/iOS: How to hide Navigation- AND ToolBar on scroll down?
I'm able to hide (or unhide using NO) the navigation bar successfully using the code:
[[self navigationController] setNavigationBarHidden:YES animated:YES];
However, when I attempt to hide the toolbar using the code:
[[self navigationController] setToolbarHidden:YES animated:YES];
Nothing happens. I then noticed when unhiding the toolbar that I received an additional blue toolbar that I didn't realize existed. This screenshot shows this:
Screenshot
I do not want the blue bar. What I am trying to do is hide or unhide the Black toolbar with the icons on it. (the UITabBar).
I think what I need to do is somehow I need to access the navigation controller of one of the parent view controllers and call the setToolbarHidden on the navigation controller of that view. However, I can't seem to figure out how to do this.
I've tried the following and all seem to have no effect:
[[[self parentViewController] navigationController] setToolbarHidden:YES animated:YES];
or
[[[[[[UIApplication sharedApplication] delegate] window] rootViewController] navigationController] setToolbarHidden:YES animated:YES];
My view controller storyboard consists of the following:
The InitialViewController is a TabBarViewController. It contains three children. One of those children is a UINavigationController. This navigation controller gets several UITableViewController pushed onto it, and eventually a UIViewController is pushed. This last UIViewController is what is seen in the screenshot.
Rough Layout:
TabBarViewController
UIViewController
UITableViewController
UINavigationController
UITableViewController
UITableViewController
UITableViewController
UIViewController
I've tried using
[self parentViewController] parentViewController] parentViewController] ...
to attempt to get back to the top, but this hasn't seemed to work either.
Any suggestions?
I think the problem here might be related to UITabBarController not having a UIToolbar. The setToolbarHidden: method will only apply to the UINavigationController's built-in toolbar (see Apple's documentation). If it's the UITabBarController's tab bar that you actually want to hide, take a look at this post which links to a method using UIView animations directly on the UITabBar.