为什么 UIScrollView 在 ios 6 和 ios 7 中从顶部留下空间

2022-10-16移动开发问题
2

本文介绍了为什么 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 中,在 storyboard 中选择你的控制器 > 在 Attribute Inspector 中禁用 Adjust Scroll View Insets还要检查你是否设置了任何 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 中从顶部留下空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End
UIScrollView

相关推荐

UIScrollView 和 Cocos2D
UIScrollView and Cocos2D(UIScrollView 和 Cocos2D)...
2024-08-12 移动开发问题
2

如何在没有 UIScrollView 的情况下放大和缩小 UIImageView?
How can i zoom in and out in a UIImageView without UIScrollView?(如何在没有 UIScrollView 的情况下放大和缩小 UIImageView?)...
2024-04-15 移动开发问题
9

iPhone SDK:UIScrollView 不滚动
iPhone SDK: UIScrollView does not scroll(iPhone SDK:UIScrollView 不滚动)...
2024-04-15 移动开发问题
11

UIScrollView 分页自动布局 &故事板
UIScrollView Paging Autolayout amp; Storyboard(UIScrollView 分页自动布局 amp;故事板)...
2023-09-12 移动开发问题
7

在 UIScrollView 的底部查看,带有 AutoLayout
View at the bottom in a UIScrollView, with AutoLayout(在 UIScrollView 的底部查看,带有 AutoLayout)...
2023-09-11 移动开发问题
1

dequeueReusableCell 打破了cliptobounds
dequeueReusableCell breaks cliptobounds(dequeueReusableCell 打破了cliptobounds)...
2023-09-09 移动开发问题
1