Extra top white space since IOS 8 using autolayout and scrollview(自 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:
- 将可滚动视图的顶部约束到滚动视图的顶部,但使用常量
-64,即额外空间的高度.我不知道为什么. - 添加一个空的
UIImageView作为UIScrollView的兄弟,并将其约束为与根视图的所有四个边齐平.
- 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. - Add an empty
UIImageViewas a sibling of theUIScrollView, 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 以来使用自动布局和滚动视图的额外顶部空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自 IOS 8 以来使用自动布局和滚动视图的额外顶部空白
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
