自 IOS 8 以来使用自动布局和滚动视图的额外顶部空白 [英] Extra top white space since IOS 8 using autolayout and scrollview

查看:26
本文介绍了自 IOS 8 以来使用自动布局和滚动视图的额外顶部空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从对 IOS8 进行了新的更新后,我在滚动视图中的内容视图上多了一个空白区域.我的内容视图应该在我的滚动视图中居中,并且在 IOS7 上运行良好.

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 storyboard version which doesn't have white space :

我想知道是什么导致了这个额外的空间,ios8 中有什么新东西会导致我的内容视图有额外的空间吗?

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 ?

谢谢!

编辑:我的解决方案是仅取消选中出现问题的视图中的调整滚动条插入.但是,我接受的以下解决方案也有效.

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.

推荐答案

我遇到了同样的问题,我想出了两个可能的解决方案,这两个都很糟糕,让我作为程序员感到羞耻:

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. 将可滚动视图的顶部约束到滚动视图的顶部,但使用常量-64,即额外空间的高度.我不知道为什么.
  2. 添加一个空的 UIImageView 作为 UIScrollView 的兄弟,并将其约束为与根视图的所有四个边齐平.
  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.

希望这只是 iOS 8 的一个错误,这样我就可以拿出我的 hack 并从窗台上走下来.

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.

这篇关于自 IOS 8 以来使用自动布局和滚动视图的额外顶部空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆