問題描述
我的應用程序中的一個屏幕必須是可垂直滾動的.它的內容或多或少是靜態的,但它不適合手機的屏幕(因此是滾動視圖).我使用 UIScrollController
作為頂視圖,我想使用 Xcode 中的情節提要編輯器來布置其中的所有視圖.我可以這樣做嗎?我顯然可以在 UIScrollController
的可見部分放置東西,但是我可以在視覺上將更多視圖放在首屏"嗎?
One of the screens in my app has to be vertically scrollable. Its contents is more or less static, but it doesn't fit on the phone's screen (hence the scroll view). I'm using a UIScrollController
as a top view, and I'd like to use the storyboard editor in Xcode to lay out all the views in it. Can I do that? I can obviously drop things on the visible part of my UIScrollController
, but can I put more views "below the fold" visually?
推薦答案
還有另一種方法可以做到這一點,它與上面評論中鏈接中給出的答案不同,我認為這更容易,因為它可以讓你看到你的以全尺寸查看整個內容并在 Storyboard 中進行設計.
There is another way to do it that is different from the answers given in the link in the comment above which I believe is easier because it allows you to see your whole content view at full size and design it in Storyboard.
- 1) 放置一個 UIScrollView 作為控制器的根視圖.
- 2) 點擊故事板中的 View Controller 并轉到屬性檢查器并將大小更改為自由格式
- 3) 單擊故事板中的滾動視圖并轉到大小檢查并更改寬度和高度到你需要的一樣大.(2,000 x 4,000)
- 4) 將 UIView 作為滾動視圖的子視圖,這將是您的內容視圖您將在其中設計屏幕并將所有子視圖.不要忘記將滾動視圖的 contentSize 設置為viewDidLoad 中此視圖的大小.
- 5) 點擊#4 中的 UIView 并在 Size Inspector 中設置 Struts 和 Springs此視圖未調整大小 .
- 6) 設計屏幕的其余部分
訣竅在于#3  將滾動視圖的大小設置為非常大,以便您進行設計.當這個 viewController 被加載到 iPhone 中時,Struts &Springs 會將 scrollView 的大小調整為 iPhone 屏幕的大小,但 contentView 會保持較大.
The trick is in #3 & #5 setting the size of the scrollView to really large so you can design. When this viewController is loaded into the iPhone the Struts & Springs will resize the scrollView to the size of the iPhone screen, but the contentView will stay large.
這篇關于在大型 UIScrollView 中直觀地排列子視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!