When I call tabbar.isHidden = true in viewWillAppear it leaves a black space. No matter what I try, nothing is helping. I have tride `hidesBottomBarWhenPushed, tried to change the tabbar size to 0 and so on. In another project of mine it works, but not in this one.
Anyone have a solution?
Oh, I am not using Storyboard, I do everything programmatically.
5 minutes later, here we are again ...
I have found the solution!
I called tabBar.isTranslucent = false in my MainTabController. When calling tabBar.isHidden = true in my other views, it did only hide the tabBar but did not make the translucent part go away.
So yea, I hope you understand the solution, if you should ever run into a similar problem, make sure to check if you call isTranslucent anywhere
Suppose you are redirecting from view controller A to B, when you are creating instance of view controller B (Inside view controller A) to redirect. Try like this it worked for me.
let vc = IKSikSearchViewController()
vc.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(vc, animated: true)
Related
I am pushing viewControllers like that:
let editProfileViewController = EditProfileViewController()
editProfileViewController.hidesBottomBarWhenPushed = true
navigationController?.pushViewController(editProfileViewController, animated: true)
But when any viewController is pushed for the first time - tab bar is not hiding, untill push animation is fully completed, it happens only once, after that even controllers that I not pushed before - have normal behaviour.
I have UITabBarController subclassed, maybe its something with backgroundColor? I tried to set it in UITabBarController, but nothing changed.
If i change animated to false, then everything works properly
I found an answer here:
https://stackoverflow.com/a/48198123/7707927
The problem was, that I was calculating TabBar height, in 'viewDidLayoutSubviews' of my subclassed 'UITabBarController'
I'm using Swift 4 with xcode 9.1. This question is somewhat confusing, so I've included images to hopefully help out.
Here is my setup:
When I navigate from VC1 to subVC1, then tab over to VC2 and into subVC2, then tab back to subVC1, everything works perfectly.
When I do the above after having typed something into the search bar in VC1, I get view A (below, black screen).
When I set definesPresentationContext = true for VC1, this solves the black screen problem but creates a new problem. Normally when you segue back from subCV1 to VC1 with something typed in the searcher, it looks like view B (below, middle panel). With definesPresentationContext = true, VC1 ends up looking like view C (below, right panel) after segueing back from subVC1. Everything is shifted up and hidden by the searchbar.
This also happens for the unnamed VC above that also navigates to subVC1.
How might I figure out why the content is being shifted up and how to fix it?
I came across this post several times while investigating a similar problem, so I wanted to post my findings here.
My UITableViewHeaderFooterView was "popping" onto the top of my search results - located in a UITableView - a split second after navigating back from a ViewController to my UISearchController.
"Under top bars" was checked in my Storyboard file as above, but I had declared definesPresentationContext in my code.
I found out that I needed to add an additional line so that the header wouldn't jump anymore:
extendedLayoutIncludesOpaqueBars = true
definesPresentationContext = true
It prevented both the "black screen" issue and the content shifting problem.
After testing out quite a lot of solutions (setting content y position, confirming proper constraints), I found the issue.
Whereas previously, my setup necessitated unchecking Extend edges under top bars, the new setup requires that it be checked. See new working setup below, which fixes all visual glitches in my original question. Hope this helps someone!
I tried to search but I can't find the right answer for me.
I tried to set a PromptText in the navigationBar but it does not work.
No matter where i put this line of Code
self.navigationController.navigationBar.topItem.prompt = #"MyTitle";
It does not work. I put it in the Child and RootViewController. The effect is that the RootView Controller has a prompt but not the ChildViewController.
Can anybody help me, please?
I don't know what you're trying to do exactly. But you shouldn't just change the topItem. Instead, change the view controller's navigation item like this:
self.navigationItem.prompt = #"MyTitle";
Depending on when it is called, it might not have the effect you expect because it depends on what topItem is at that time. Instead, set the prompt from each view controller's navigationItem.prompt.
I have this MonoTouch related question, but I think Objective/C programmers can help as well.
I have TabBarController with some tabs. I want my home viewController (which is added to tabBar) to appear without tabBar.
I thought the way to do it was to set HidesBottomBarWhenPushed of that controller to true.
homePage = new HomePageController();
homePage.HidesBottomBarWhenPushed = true;
homePage.TabBarItem = new UITabBarItem("Home", new UIImage("Images/Icons/home.png"), 0);
However, it seems that this works only in case of using TabBar with NavigationController, i.e. in case we actually push controllers.
I wonder if there is a way to do it just for simple viewControllers contained in tabBarController.
You can try to set the hidden property of the tab bar to YES. (or true in MonoTouch)
I found out that, in fact, you cannot cover tabBar area of tabBarController. You can set hidden property, just like Moshe said, or you can play with opacity as well but can't cover it with anything.
But there's a great alternate solution. You can use modal view, which always has higher index than regular controllers. Therefore, it will cover everything.
homePageContent.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
homePageContent.ModalTransitionStyle = UIModalTransitionStyle.CoverVertical;
this.PresentModalViewController(homePageContent, false);
base.ViewWillAppear (animated);
I have a UIViewController that is pushed onto a UINavigationController and is currently displayed. When I go to start some asynchronous task inside the view controller, I can set hidesBackButton on self.navigationItem to YES, and the back button is hidden correctly.
As soon as the task is finished, and I set hidesBackButton back to NO (on the UI thread, I might add, I've made sure of this), nothing happens. The back button remains hidden.
Has anyone seen this before? What drives me especially crazy is that in my application (the same application), in a different UINavigationController hierarchy, the exact same code works correctly!
Are you calling hidesBackButton = NO from a thread? All UI operations should be done on the main thread, otherwise they won't have any effect.
i have not been able to replicate your problem on my machine. however, i faced a similar issue with tableviews even when i was updating my ui on the main thread. but calling setNeedsDisplay fixed that issue.
Can you try this and see if this works:
[self.navigationController.navigationBar setNeedsDisplay];
I guess this should work, you need to do the same, BUT ON THE NAVIGATIONBAR instead. please let me know if this worked - as i cannot test my solution because i never get this problem :-)
Have you tried forcing the view to refresh by calling setNeedsDisplay?
Maybe the OS is not picking up the changes instantly and you need to force it.
Have you tried using the setHidesBackButton:animated: method instead? Perhaps that has a slightly different behavior.
In my case I simply had to give a title to the view, as in:
self.navigationItem.title = #"Menu";
Marinus
I have had a similar issue recently. I tried literally everything I found in SO and other forums- nothing worked.
In my case there was a modally shown UINavigationController with a simple root controller which would push one of two view controllers (A and B) on top of the controller stack when the button A or B was pressed, respectively. Controller B was the one which was not supposed to show the back button. But still, sometimes it did, sometimes it didn't.
After hours of debugging, I managed to track it down. Controller A was a UITableViewController. Each time I selected a cell in this controller, the delegate would pop Controller A off the stack. BUT. I made use of a UISearchDisplayController as well. Turned out that popping the view while the search controller was still active messed up something in the navigation controller that made it impossible to hide the back button in Controller B afterwards (well, it eventually stayed hidden between viewDidLoad and viewDidAppear: but then it always turned visible).
So the solution (rather workaround) was adding this line to where Controller A was dismissed:
controllerA.searchDisplayController.active = NO;
// ...
// [self.navigationController popViewControllerAnimated:YES];
Hope this spares someone a couple of hours.