問題描述
雖然我過去通過編程操作成功地使用了 UIScrollView
,但我無法通過僅在 Interface Builder 中設(shè)置它來使其工作.
While I've used UIScrollView
successfully in the past by manipulating it programmatically, I'm having trouble getting it to work by setting it up exclusively in Interface Builder.
我的 iPhone 應(yīng)用中有一個(gè)簡(jiǎn)單的關(guān)于"頁面.它有一個(gè) UITextView
、一些圖標(biāo)和指向我的其他應(yīng)用程序的鏈接.我已將所有這些視圖添加到我的 UIScrollView
中,并對(duì)其進(jìn)行排列以使它們的總大小 > 480.當(dāng)我啟動(dòng)我的應(yīng)用程序時(shí),滾動(dòng)視圖僅顯示適合屏幕的內(nèi)容,并且沒有滾動(dòng).
I have a simple "about" page in my iPhone app. It has a UITextView
, some icons, and links to my other apps. I have added all of these views to my UIScrollView
, arranging them so that their total size is > 480. When I launch my app, the scrollview displays only the contents that fit on the screen, and nothing scrolls.
是否可以完全通過 IB 來完成,還是必須通過代碼來操作 contentSize?
Is it possible to do this entirely via IB, or must I manipulate the contentSize via code?
推薦答案
你忘記設(shè)置 UIScrollView 的 contentSize 屬性了.奇怪的是,您不能從 Interface Builder 執(zhí)行此操作.您必須從管理此滾動(dòng)視圖的視圖控制器中執(zhí)行此操作.
You forgot to set the contentSize property of the UIScrollView. Strangely enough you can not do this from Interface Builder. You will have to do it from the view controller managing this scroll view.
這篇關(guān)于如何在 Interface Builder 中使用 UIScrollView?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!