为什么UIScrollView会将空间留在顶部而不会滚动到底部 [英] Why is UIScrollView leaving space on top and does not scroll to the bottom
问题描述
我是Objective-C编程的新手。
I am new to objective-C programming.
我正在使用带有标签,图像和文本视图的UIScrollView。
I am using UIScrollView with some labels, image and text view on it.
我已关闭Autolayout并且已经尝试使用调整滚动视图插入(标题中描述的情况)和关闭(不滚动)。
I have turned off Autolayout and already tried with "Adjust scroll View Insets" on (situation described in title) and off (doesn't scroll).
这是我插入到viewDidLoad中的内容:
This is what I insert into viewDidLoad:
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 687)];
但我必须遗漏一些非常简单的东西。
But I must be missing something very simple.
推荐答案
1 ...为什么UIScrollView将空间留在最上面
1... Why is UIScrollView leaving space on top
使用故事板 - 转到视图控制器>属性检查器>取消选中调整滚动视图插入属性
With Storyboard- Goto view controller > Attribute Inspector > Uncheck Adjust Scroll View Insets property
使用代码 - 对于额外的空间集 viewController
property automaticAdjustsScrollViewInsets
to NO
,默认情况下,它是 YES
。
With Code- For extra space set viewController
property automaticallyAdjustsScrollViewInsets
to NO
, by default it is YES
.
self.automaticallyAdjustsScrollViewInsets = false;
scroller.contentInset = UIEdgeInsetsZero;
scroller.scrollIndicatorInsets = UIEdgeInsetsZero;
scroller.contentOffset = CGPointMake(0.0, 0.0);
2 ...不会滚动到底部
2... does not scroll to the bottom
要使其滚动尝试在 contentSize
中使用大数字,如 CGSizeMake (320,1687)
。如果它有效则意味着您没有将 contentSize
设置得足够大以包含其所有内容。
To make it scroll try with large number in contentSize
like CGSizeMake(320, 1687)
. If it works that means you are not setting the contentSize
large enough to have all its content.
这篇关于为什么UIScrollView会将空间留在顶部而不会滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!