問題描述
我是故事板的新手;我之前做過一些 Interface Builder 和很多手動 UI 定位.我搜索了這個(gè)問題,嘗試了其他相關(guān)帖子中的解決方案,但無濟(jì)于事.
I'm new to Storyboards; I've done some Interface Builder before and lots of manual UI positioning. I've searched this issue, tried the solutions found in the other relevant posts, to no avail.
我有一個(gè)在 Storyboards 中添加了 UIScrollView 的視圖控制器.ScrollView 插座已連接,屬性已合成.滾動啟用被選中.彈跳已檢查.即便如此,也沒有跡象表明會發(fā)生任何滾動.當(dāng)我檢查 Bounces Vertically 時(shí),我至少可以看到可滾動的內(nèi)容,但在我釋放后它會反彈回來.我發(fā)現(xiàn)的框架尺寸設(shè)置為 320 和 521.我嘗試了不同的高度,但沒有任何幫助.(Storyboards 中設(shè)置的尺寸應(yīng)該是多少,以適應(yīng)新舊手機(jī)尺寸?).
I have a view controller with a UIScrollView added in Storyboards. The ScrollView outlet has been connected, the property synthesized. Scrolling Enabled is checked. Bounces is checked. Even then there was no indication that any scrolling would take place. When I checked Bounces Vertically, I could at least see the scrollable content, but it bounces back after I release. The frame size I found set at 320 and 521. I experimented with different heights but nothing helped. (What ought to be the size set in Storyboards that will accommodate the older and newer phone sizes?).
在viewDidLoad中,我添加了
In viewDidLoad, I added
[scrollView setContentSize:CGSizeMake(320, 1000)];
隨后的日志語句確認(rèn)該值已被接受.但這也無濟(jì)于事.
A log statement afterwards confirms that this value has been accepted. But it didn't help either.
有人在一篇帖子中建議添加:
Someone in one post suggested adding:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[self.scrollView setContentSize:CGSizeMake(320, 808)];
}
這會在控制器加載時(shí)導(dǎo)致程序崩潰.
This had the effect of crashing the program when the controller loaded.
任何幫助將不勝感激!
謝謝.
推薦答案
事實(shí)證明有兩件事是必要的:
Two things turned out to be necessary:
1) 將滾動視圖的高度設(shè)置為 480.
1) Set height of scrollview to 480.
2) 將約束添加到滾動視圖的最底部字段.約束是 Pin >> Bottom Space to Superview.
2) Add constraint to the bottommost field in the scrollview. The constraint was Pin >> Bottom Space to Superview.
這篇關(guān)于UIScrollView 不會滾動(故事板)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!