問題描述
我正在使用 swift 構建應用程序.我想使用情節提要向我的視圖控制器添加一些內容.
我已經把所有東西都放在了滾動視圖中并設置了特定的高度,但是當我運行應用程序時,滾動視圖總是設置得比視圖底部的按鈕長
我希望滾動視圖在按鈕之后立即停止
請幫我解決這個問題
謝謝
滾動后
為了您的信息,請忽略 'critics' 和提交按鈕之間的空白,因為實際上它們之間有 UITextView 但不可見(仍然嘗試添加一些邊框)
這些是我的故事板預覽
1) ScrollView Contraints
2) ScrollView -> contentView 滾動視圖的約束與上圖相同
3) 現在 ContentView 的寬度和高度約束到主視圖[嵌入了 ScrollView 的 SuperView] 和約束如下.
4) 現在單擊 EqualWidth 以查看 [從頂部開始的第三個約束] 并按照步驟 6 進行編輯
5) contentView 寬度約束
6) ContentView 高度約束//設置優先級 [必須] .在這里,您需要將菜單中的第一項和第二項更改為如圖所示 First as - ContentView.Height 和第二個 as - View.height 并將優先級設置為 250 在此之后,情節提要中將出現一條虛線沿 contentView
7) 現在在 contentView 中添加 [UIView, labels, textfields] 之類的內容,并將約束作為 Top upperMost 視圖頂部空間添加到 contentView [就像我一樣]DoubleRight imageView
我的 DoubleRight imageView 的約束是
在給定頂部空間 20 點的情況下查找頂部空間邊距
同樣你需要為你將添加到 ContentView 中的最后一個項目做同樣的事情,就像我有 uiView 一樣
將各自視圖的底部空間添加到您的 superView[ContentView] 中,我的約束是:
在您初始化所有這些步驟后,每個屏幕尺寸的結果都將與預期一樣,無需額外更改屏幕尺寸的高度
注意:-[所有視圖必須通過 top 和 bottom 參數相互連接]
像 Flow 一樣
View1 - 頂部到 contentView,底部到 View2View2 - 從頂部到 View1,從底部到 view3View3 [Last view] - 頂部到 View2 和底部到 contentView,如圖所示
使用uiView,uiimageViews的高度必須是固定的
I'm using swift to build an application. I want to add some content to my view controller using storyboard.
I already put everything inside the scrollview and set the specific height, but however when I run the application, the scrollview always set longer than the button in the bottom of the view
I want the scroll view stop right after the button
Please kindly help me how to solve this problem
thank you
after scrolling
for your information, please ignore the white space between 'critics' and submit button, because actually there's UITextView between them but not visible (still try to add some border)
these are my storyboard preview
1) ScrollView Contraints
2) ScrollView -> contentView Constraints to scroll View same as above image
3) now ContentView width and Height Constraints to main View [SuperView in which ScrollView is embedded] and constraints will be as follows.
4) now click on the EqualWidth to View [Third constraint from top]and edit it as in step 6
5) contentView Width Contraint
6) ContentView Height Constraint // set priority [must] . here you need to change the first item and second item in the menu to as shown First as - ContentView.Height and second as - View.height and set priority to 250 after this a dotted line will appear in storyboard along the contentView
7) now add the content like [UIView, labels, textfields] in contentView and add constraints as Top upperMost view top space to contentView [like I have]DoubleRight imageView
and constraints for my DoubleRight imageView are
look for the Top space margin its given a top space 20 points
and same you need to do for the last item you will be adding in ContentView like I have uiView
add bottom space from this respective view to your superView[ContentView] and my constraints are:
after you had initialed all these steps results will be as Expected for every Screen size no need to change height additionally for screen sizes
Note : - [all the views must be connected to each other with top and bottom parameter]
like Flow will be
View1 - top to contentView and bottom to View2
View2 - top to View1 and bottom to view3
View3 [Last view] - top to View2 and bottom to contentView as shown
using uiView, uiimageViews their heights must be fixed
這篇關于如何在 Swift 中設置 UIScrollView 高度的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!