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'
Related
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)
The docs for both currentContext and overCurrentContext have an identical description.
The differences I can spot are:
since when they are available:
#available(iOS 3.2, *)
case currentContext
#available(iOS 8.0, *)
case overCurrentContext
With currentContext, after dismissing the presented view controller, viewWillAppear of the covered view controller gets called (which doesn't have to be the view controller that provides the context). With overCurrentContext it does not get called.
Is there any other difference?
It's exactly the same as the difference between fullScreen and overFullScreen. The first removes the view from the area it covers; the second doesn't, it merely covers it.
(In both cases, this difference is easy to see visually if your presented view controller's main view's background color has some transparency. But the differences for behavior are even more important; some views become unhappy when they are abruptly ripped out of the view hierarchy, so it could be better to leave them in place and use the .over variant.)
With currentContext, after dismissing the presented view controller, viewWillAppear of the covered view controller gets called (which doesn't have to be the view controller that provides the context). With overCurrentContext it does not get called.
That's just a consequence of what I just said. With over, viewWillAppear is not called on dismissal because the view never disappeared in the first place; it just sat there behind the presented view. Again, that's completely parallel to fullScreen and overFullScreen.
So i have a tab bar controller and when I select into the second tab it brings me to a table view controller. I have it setup so that when the viewWillAppear it animates the cells in. The problem I am having is that the first time I go into that view, everything is stationary, but if i go to another tab and come back, everything animates perfectly.
How can I get it to animate in the first time I go to the tab as well?
I have not included code because I do not think it will help answer the question.
Edit* I can go to the tab as many times as I want and it will animate each time, but will never animate on the first load of the app.
I had a very similar issue with viewDidAppear. My problem was that I called the viewDidAppear function in the TabBarController to do some stuff but forgot to call super.viewDidAppear(true) in this Method. Because of that the viewDidAppear of the child wasn't called. After I added it everything works like a charm.
So be sure to add super.viewDidAppear(true) or in your case super.viewWillAppear(true) in the TabBarController. Maybe it helps
I had the same issue. Tried the below in "ViewDidAppear" and it is working.
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.tableView.reloadData()
})
When I press back twice really quickly on the UINvaigationBar, then the UINavigationBar animates before the view, and then when the view finally animates the bar becomes blank. When I NSLog(#"",self.navigationItem.title) is prints the correct title. Does anyone have any ideas how to resolve this?
I've seen this happen when the init/loadView of a view controller that's being pushed takes a non-negligible time- perhaps the viewWillAppear of your new view controller or the viewDidDisappear of the old is taking some time?
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.