問題描述
雖然我過去通過編程操作成功地使用了 UIScrollView
,但我無法通過僅在 Interface Builder 中設置它來使其工作.
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 應用中有一個簡單的關于"頁面.它有一個 UITextView
、一些圖標和指向我的其他應用程序的鏈接.我已將所有這些視圖添加到我的 UIScrollView
中,并對其進行排列以使它們的總大小 > 480.當我啟動我的應用程序時,滾動視圖僅顯示適合屏幕的內容,并且沒有滾動.
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?
推薦答案
你忘記設置 UIScrollView 的 contentSize 屬性了.奇怪的是,您不能從 Interface Builder 執行此操作.您必須從管理此滾動視圖的視圖控制器中執行此操作.
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.
這篇關于如何在 Interface Builder 中使用 UIScrollView?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!