Gap between top of UIScrollView and adjoining view - ios

I'm trying to figure out why there's a gap between my scroll view (topped by the pink) and the upper view (black).
I have created this in interface builder. The pink view is inside a UIScrollView that is set to have its top == bottom of the black view above it:
Why is there this gap and how can I stop it?
Here is a slice of the entire screen to give you an idea:
I am having the same difficulty both at the top and bottom of the scroll view. There is a white gap between the top view of the scroll view and the next view up, and similarly there is a gap at the bottom view for the scroll view and the bottom of the screen. I tried turning off 'bounces enabled' but that has not fixed the problem. What gives?

Related

UIScrollView too close on home bar

Whenever I run my iOS app on a device that has a home bar, the bottom of a UIScrollView or one of its descendants will render too low.
My app has a bottom navigation. I made the scroll view constrained to the safe area on the Y axis. It contains a container view (Cv For Home) in which I load a subview:
The container view is constrained to the superview (scroll view), though.
In my child storyboard's subview I have a collection view, that I have to constrain a lot from the bottom of the superview away, oddly enough. Otherwise it will not display entirely on the devices:
That's weird, but it works, unless I run the app on a device with home bar. I think this might be related, but I'm pretty new to constrains and I can't get it right for some reason.
The result, then, looks like this:
As you can see the last cells are hidden below the bottom navigation on the middle and right device. Both have a home bar, the left device does not. How can I fix this?
EDIT: The bottom navigation looks like this:
I also tried to set the bottom constraint of the scroll view to the top of the bottom navigation, but that was resulting in the same issue.
EDIT 2: Taking a look at the Debug View Hierarchy reveals in fact, my Safe Area is too long, so it seems that it has a fixed height and using a bottom constraint on the bottom edge of the Safe Area will break if there is a home bar:
The parent UIView has the correct size.

How to centre the image view within a collection view cell after zooming?

I have a collection view in which i have set of images to be displayed.
Im trying to zoom the image view inside a collection view with the help of a scroll view. But when i zoom a black patch is visible if i pan to the bottom or top of the scroll view after zooming. I don't know how to eliminate the black patch.
The black patch is visible because my image view is having width and height same as the scroll view and the content mode is aspect fit so that even the portrait image should be fit within the cell.
I have my scroll view as subview of the cell and image view as subview of the scrollView My scroll view and its constraints goes here
The screen shot after zooming and panning to the Bottom of the scroll view the red highlighted area shows the black patch.
I have posted a question on stack overflow recently in which i tried to solve this but i got some problems with that too How to zoom the image view within collection view effectively??

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.

UIView Under Nav and Tab Bars

Using storyboard and Swift, I have a view controller which has two elements on it. A UITextField, and a UIView, which I use merely to give a colored border to the UITextField. The UITextField is a child of the UIView. See:
The problem I am having is that despite having set the top bar and bottom bar simulated metrics attributes to Opaque Navigation Bar and Opaque Tab Bar respectively, See:
When the app builds and runs the top of the UIView is always underneath the nav bar. My over all feeling is that this is somehow a constraints issue but I have not been able to find the solution to it. How do I set the constraints so that the UIView is always immediately underneath the nav bar, and the bottom of the view is always just on top of the tab bar?
Select your UIView in storyboard and assign constraints to the top margins and to bottom margins. There is a 'Pin' button you use to do this that looks something like a Tie-Fighter ship in Star Wars, it is located at the bottom right of your storyboard view.
This will set margins to stretch to top and bottom always.
That is what the layout guides are for. Pin the top to the Top Layout Guide and the bottom to the Bottom Layout Guide. The guides will always move to adjust for any top and bottom bars.

Navigation controller and ScrollView Top Layout Guide Margin

I am trying to align a "view" at the top of the screen but below the navigation bar. The view is inside a scrollview. The problem is that there is a gap at the top, where the top layout guide is not honored. I am writing this in Swift. Any solutions? I am attaching a photo of what's going on.
Basically, I want to remove the white part between the navigation controller and the blue background.
I also adding a snapshot of the constraints.

Resources