Why is UIScrollView leaving space on top and does not scroll to the bottom(为什么UIScrollView在顶部留下空间并且不滚动到底部)
问题描述
我是 Objective-C 编程的新手.
我正在使用带有一些标签、图像和文本视图的 UIScrollView.
我已经关闭了自动布局,并且已经尝试开启(标题中描述的情况)和关闭(不滚动)调整滚动视图插图".
这是我在 viewDidLoad 中插入的内容:
[scroller setScrollEnabled:YES];[滚轮 setContentSize:CGSizeMake(320, 687)];
但我一定遗漏了一些非常简单的东西.
1...为什么UIScrollView在顶部留下空间
使用 Storyboard- 转到视图控制器 > 属性检查器 > 取消选中 Adjust Scroll View Insets 属性
With Code- 额外空间设置
viewController
属性automaticallyAdjustsScrollViewInsets
为NO
,默认为是代码>.
self.automaticallyAdjustsScrollViewInsets = false;scroller.contentInset = UIEdgeInsetsZero;scroller.scrollIndicatorInsets = UIEdgeInsetsZero;scroller.contentOffset = CGPointMake(0.0, 0.0);
<块引用>
2...不滚动到底部
要使其滚动,请尝试在 contentSize
中使用较大的数字,例如 CGSizeMake(320, 1687)
.如果它有效,则意味着您没有将 contentSize
设置得足够大以容纳其所有内容.
I am new to objective-C programming.
I am using UIScrollView with some labels, image and text view on it.
I have turned off Autolayout and already tried with "Adjust scroll View Insets" on (situation described in title) and off (doesn't scroll).
This is what I insert into viewDidLoad:
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 687)];
But I must be missing something very simple.
1... Why is UIScrollView leaving space on top
With Storyboard- Goto view controller > Attribute Inspector > Uncheck Adjust Scroll View Insets property
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... does not scroll to the bottom
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在顶部留下空间并且不滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么UIScrollView在顶部留下空间并且不滚动到底


基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01