为什么UIScrollView在ios 6和ios 7中从顶部留出空间 [英] why UIScrollView is leaving space from top in ios 6 and ios 7

查看:90
本文介绍了为什么UIScrollView在ios 6和ios 7中从顶部留出空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已关闭Autolayout和viewcontroller嵌入在导航控制器中。
我正在使用Xcode 5,Storyboard。

I have turned off Autolayout and viewcontroller is embedded in navigation controller. I am using Xcode 5, Storyboard.

我不明白为什么它会从顶部留下空间。
实际上在故事板中我把我的标签正好放在导航栏下方。
但是当我在模拟器上运行它然后它从顶部留下空间。

I don't understand why is it leaving space from top. Actually in storyboard i have put my label exactly below navigation bar. But when i run it on simulator then it leaves space from top.

解决此问题的一种黑客方法

One of the hacky way to resolve this

-(void)viewWillLayoutSubviews
{
   self.scrollViewMain.frame = CGRectMake(0, -70, 320, 800);

   self.scrollViewMain.contentSize = CGSizeMake(320, 800);
}

但我错过了一些非常简单的方法。

推荐答案

在Xcode 5中,在故事板中选择您的控制器>在属性检查器中禁用调整滚动视图插入
同时检查是否你设置了任何contentInset

In Xcode 5, in storyboard select your controller > in Attribute Inspector disable Adjust Scroll View Insets Also check if you have set any contentInset

编辑:我附上了一张图片

这篇关于为什么UIScrollView在ios 6和ios 7中从顶部留出空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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