view shifts down after being presented on screen when hiding tabBar in a navigationController stack in iOS - ios

I am trying to hide my tabBar when pushing to a new viewController. I achieve this by ticking Hide Bottom Bar on Push in storyboard. The problem is that the new view that is being pushed to momentarily shows it's original position (as if the tabBar was still there) before shifting downwards to the correct position.
After searching for some time I found a similar post:
Auto Layout and "Hide bottom bar when pushed"
Unfortunately the solution of selecting the bottom constraint of the new view to Bottom Layout Guide.Bottom is no longer available in iOS 9 (it is greyed out). I followed several suggestions to set the bottom constraint to the container margin but it did not help this shift downwards.
Has anyone found a solution for this problem? It seems the geometry of hiding the tabBarController is only recognised after the push transition has completed.

It turns out my inputAccessoryView was causing the odd scrolling behaviour. The solution that worked for me was to add view.layoutIfNeeded() just before returning the accessoryView in the override:
override var inputAccessoryView: UIView? {
get {
view.layoutIfNeeded()
return accessoryView
}
So for this special case that involves a navigationController embedded in a tabBarController where you like to push to a viewController that hides the tabBar:
check Hide Bottom Bar on Push on storyboard
pin the bottom of the view you are presenting to the container bottom (use method suggested above or just select the pin icon at the bottom of your screen and on the bottom constraint select the drop down arrow and pin to view)
Then finally if you are using an inputAccessoryView, add layoutIfNeeded() in the override to the getter as I have done above.

In Xcode7 you have to right click your element, draw a line to the bottom until the constraint selector pops up. Constraint selector
Then press ALT and now you'll get the desired Bottom constraint

Related

constraint update cause item move when using hide button on push with autolayout

first, please check out the problem (note the gray belt thing will be moved during the navigation push view)
I have made autolayout constraint with storyboard like this:
And to hide the tab bar to fully display the image(and prevent user to click to other tabs) I have hide bottom bar on push checked:
But now the gray belt is moving during view changing.
How to fix this?
Constrain the bottom to the view.bottomAnchor, and not to the BottomLayoutGuide.top. You can do it in attribute inspector when you select the constraint.

Hide Bottom Bar When Pushed through Autolayout

I have a UITabBarController with one UINavigationController holding a UIViewController as root view controller.
when tapping one of the button in the UIViewController, I push a regular chat window UIViewController (with TableView + Input View) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)
In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.
The problem
when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.
For clear info check this screen shot
Now I will let you the know the constraints of the table view..
Now I am showing the constraints of the InputView
I am also adding my View hierarchy...
I had a similar issue in my project. I solved it by selecting the view I wanted anchored to the bottom (in your case, the input view), held Command, and selected its superview (both views should be highlighted now).
Then I selected the align button at the bottom of IB:
And added a Bottom Edges constraint.
What I had done initially is used the pin menu to pin the view to its superview, but it appears that will pin it to the bottom layout by default, which causes that weird movement during the transition.
EDIT:
After seeing the latest screenshot, the problem could lie in one of the superviews. I'm assuming that chatWindow is a UIView, and your Scroll View is horizontal only. Here's what your should check:
chatWindow is pinned to the scrollView's bottom similar to what I've outlined above.
scrollView is pinned to its superview as I've outlined above.
Moving the inputView outside of the scrollView to the root superview. Then one by one move it down the hierarchy towards its current location.

Table view top space to navigation bar increased after pressing back

When I click one of the cells in the table view, it opens a new view with the following code:
let fullResView : FullResponseViewController = self.storyboard?.instantiateViewControllerWithIdentifier("FullResponseView") as! FullResponseViewController
fullResView.receivedPost = post
self.navigationController?.pushViewController(fullResView, animated: false)
When I press back, it increases the distance between the table view and the Top Layout Guide. Representation:
Hierarchy:
I have a tab bar controller, that is embedded in a navigation controller.
The table view is drag & dropped after creating an normal view. So the table view is inside a View.
Table view does contain an header view. When setting a background color for this, it moves together with it, so it should not be anything with those constraints.
constraints for the table view are:
equal with to superview
Align Center X to superview
top space to Top Layout Guide
bottom space to Bottom Layout Guide
I've tried the following:
set this in viewWillAppear:
self.responsesTableView.contentOffset = CGPointMake(0, 0)
self.automaticallyAdjustsScrollViewInsets = false
This did work when I pressed back, then switch to another view in the tab bar, and then switch back again. Without contentOffset it will stay like this forever.
As i seen the OP images that seems like Navigation translucent property Issue. Because after push a viewcontroller there is same 44px white space. so it means if your Navigation translucent property is true then your UITableview start from 0th Y position. And if your Navigation translucent property is false then UITableview start from 44px Y position.
So i guess in between push and back some where UINavigation's translucent become a true and false. make following one line add in your appdelegate class in DidFinish method:
UINavigationBar.appearance().translucent = false
This is appearance of UINavigationBar for make this false globley in your project. Hope that will be fix your issue.
I'm not sure if this is related to your particular issue, but it's worth checking whether your UITableView is the first control on your screen:
Why is there extra padding at the top of my UITableView
Even in the latest version of Xcode, this is a bug. But it's easy enough to fix, if you know how to get around it.

ViewController not responding to touches

I have a ViewController in which there is a navigation bar, toolbar and a tableview. I have pinned the navigation bar to top, left and right and fixed the height. I have pinned the toolbar to bottom, left and right and fixed the height. I have pinned the tableview to top, bottom, left and right. Now not even the item bar buttons nor the TableViews respond to touches. I have added a screenshot for the same.I have checked and have added the actions and outlets right.My other views are working perfectly fine.
You should have provided with some code.Once I faced the same problem.Then after some brainstorming I found that the problem was in my code,not view controller.I added some code to find latitude and longitude,turns out that gps kept searching location continuously in the background and for that reason,nothing in view controller responded to touch.

Constraint to bottom layout guide with TabBar issue

I have UITabBarController based iPad app with containerView on the first tab. The containerView has standard vertical spacing to bottom layout guide. When I tap on the second tab and then go back to the first tab, my container moves down by 56 pts, the height of the tabBar and is then covered by the tabBar.
I made 3 screenshots to illustrate that. The third screenshot shows hidden tabBar after the jump between tabs. It looks like the bottom layout guide went down to the edge. What is going on here?
I'm not sure about what happened here, but I think that this could help:
Uncheck Under bottom bar in your UIViewController properties
Hope that will help!
Nicolas Bonnet's answer of unchecking "Extend Edges Under Bottom Bar" didn't work for me. In my case the problem seemed to be that I was setting the bottom constraint of my view equal to the Bottom Layout Guide.
So, instead, I aligned the bottom edges of my button and the ViewController's view as shown below.
Select both your view to pin to the bottom and the main view:
Then tap the Align selection menu at the bottom right of Interface Builder and select Bottom Edges:

Resources