問(wèn)題描述
我是 Objective-C 編程的新手.
我正在使用帶有一些標(biāo)簽、圖像和文本視圖的 UIScrollView.
我已經(jīng)關(guān)閉了自動(dòng)布局,并且已經(jīng)嘗試開啟(標(biāo)題中描述的情況)和關(guān)閉(不滾動(dòng))調(diào)整滾動(dòng)視圖插圖".
這是我在 viewDidLoad 中插入的內(nèi)容:
[scroller setScrollEnabled:YES];[滾輪 setContentSize:CGSizeMake(320, 687)];
但我一定遺漏了一些非常簡(jiǎn)單的東西.
1...為什么UIScrollView在頂部留下空間
使用 Storyboard- 轉(zhuǎn)到視圖控制器 > 屬性檢查器 > 取消選中 Adjust Scroll View Insets 屬性
With Code- 額外空間設(shè)置viewController
屬性automaticallyAdjustsScrollViewInsets
為NO
,默認(rèn)為是代碼>.
self.automaticallyAdjustsScrollViewInsets = false;scroller.contentInset = UIEdgeInsetsZero;scroller.scrollIndicatorInsets = UIEdgeInsetsZero;scroller.contentOffset = CGPointMake(0.0, 0.0);
<塊引用>
2...不滾動(dòng)到底部
要使其滾動(dòng),請(qǐng)嘗試在 contentSize
中使用較大的數(shù)字,例如 CGSizeMake(320, 1687)
.如果它有效,則意味著您沒有將 contentSize
設(shè)置得足夠大以容納其所有內(nèi)容.
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.
這篇關(guān)于為什么UIScrollView在頂部留下空間并且不滾動(dòng)到底部的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!