問題描述
我是 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在頂部留下空間并且不滾動到底部的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!