Extra top white space since IOS 8 using autolayout and scrollview
Asked Answered
R

5

7

Since the new update to IOS8, i have an extra white space over my contentview in my scrollview. My content view should be centered in my scrollview and it's work fine on IOS7.

Here is the result :

enter image description here

Here is the storyboard version which doesn't have white space :

enter image description here

I'm wondering what could cause this extra space, is there anything new in ios8 that will cause my content view to have extra space ?

Maybe i need to change how i layout my view ?

Thanks!

EDIT: My solution was to only uncheck adjust scroll bar inset in my views which had the problem. However the solution below that i accepted works too.

Revet answered 25/9, 2014 at 20:32 Comment(3)
By chance do you have Adjust Scroll View Insets checked on the Title View Controller's Attributes Inspector? What about Extend Edges under opaque bars? It appears that your scroll view is not extending underneath your top bar.Ataractic
Adjust scroll bar inset is checked and both extend under top/bottom bar is check. If i uncheck only AdjustScroll well the view is actually not centered but right under the nav bar.Revet
I have used solution from your edit and its working perfect.Myrtismyrtle
D
2

I had this exact same problem, and I came up with two possible solutions, both of which are awful and make me ashamed to be a programmer:

  1. Constrain the scrollable view's top to the top of the scroll view, but with a constant of -64, which is the height of the extra space. I don't know why.
  2. Add an empty UIImageView as a sibling of the UIScrollView, and constrain it to be flush with all four sides of the root view.

I'm hoping that it's just an iOS 8 bug so that I can take out my hack and step down off the ledge.

Departmentalism answered 26/9, 2014 at 5:17 Comment(2)
Use rather solution from OP EditMyrtismyrtle
At the time this was first answered, the adjust scroll inset didn't work as expected.Departmentalism
S
6

I faced the same issue in iOS 8, following is solution I found: - Select View Contoller (in storybord) in which you have added the scroll view - In "Property Inspector" in "Layout" section un-check "Adjust Scroll View Insets"

Surprise answered 26/6, 2015 at 3:58 Comment(1)
This solved my problem without any additional tweaks. +1Elexa
O
6

Try this at your viewDidLoad for that scrollview:

self.automaticallyAdjustsScrollViewInsets = NO;
Ohmage answered 25/7, 2015 at 6:50 Comment(1)
Work for me only set ViewController.automaticallyAdjustsScrollViewInsets in StoryboardTavarez
D
2

I had this exact same problem, and I came up with two possible solutions, both of which are awful and make me ashamed to be a programmer:

  1. Constrain the scrollable view's top to the top of the scroll view, but with a constant of -64, which is the height of the extra space. I don't know why.
  2. Add an empty UIImageView as a sibling of the UIScrollView, and constrain it to be flush with all four sides of the root view.

I'm hoping that it's just an iOS 8 bug so that I can take out my hack and step down off the ledge.

Departmentalism answered 26/9, 2014 at 5:17 Comment(2)
Use rather solution from OP EditMyrtismyrtle
At the time this was first answered, the adjust scroll inset didn't work as expected.Departmentalism
T
1

in ViewDidLoad() set rootScrollView.contentInsetAdjustmentBehavior = .never

work for me

Tavarez answered 19/5, 2021 at 11:51 Comment(0)
I
0

untick the Extend Edges: under top bars of the main view and make the top distance of the subview 0 instead of negative value. this works for me.

Intermeddle answered 7/10, 2015 at 2:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.