[英]How can I place two views in a single screen using autolayout Constraints
I would like to create apps which have 2 views (top & bottom). 我想创建具有2个视图(顶部和底部)的应用程序。
The top view is scrollable and contains multiple textfields and labels. 顶视图是可滚动的,包含多个文本字段和标签。
The bottom view is non-scrollable but needs to auto adjust to fit into bottom screen like a keyboard when the screen size is changed (I want it to be usable from iPhone 4 to 6 Plus). 底部视图是不可滚动的,但需要在屏幕尺寸改变时自动调整以适应键盘的底部屏幕(我希望它可以从iPhone 4到6 Plus使用)。 The bottom view will contain a custom function button to trigger actions and updates in the top view.
底部视图将包含一个自定义功能按钮,用于在顶视图中触发操作和更新。
I have this working on Android with LinearLayout, but I'm stuck with iOS. 我使用LinearLayout在Android上工作,但我坚持使用iOS。
Try to place table view or scroll view in top which will scroll and a UIView on bottom. 尝试将表格视图或滚动视图放在顶部,滚动视图和底部的UIView。 make the height of UIView constant and table view or scroll view which you will use in top will change the height according as the screen size.
使UIView的高度保持不变,您将在顶部使用的表视图或滚动视图将根据屏幕大小更改高度。 If you got confused the post the comment.
如果你对评论发布感到困惑。
For table view see this tutorial iOS - Custom table cell not full width of UITableView 对于表视图,请参阅本教程iOS - 自定义表格单元格不是UITableView的全宽度
Step1 : Place table view and view as below .
第一步:放置表格视图和视图如下。 upper part is table view and lower is view
上半部分是表视图,下部是视图
Step2: Place the constraints for view as below
第2步:为视图放置约束,如下所示
AT first
首先
At second
第二个
Step 3: Place the constraints for table view as below
第3步:放置表视图的约束,如下所示
Try and inform me what u got 试着告诉我你得到了什么
In your case I will suggest to drag all those buttons into a UIView
. 在你的情况下,我建议将所有这些按钮拖到
UIView
。 Then place the buttons with the desired spacing. 然后放置所需间距的按钮。 Select all the buttons and give equal width and equal height constraint.
选择所有按钮并给出相等的宽度和相等的高度约束。 And then give spacing constraints between neighbour buttons or views.
然后在邻居按钮或视图之间给出间距约束。 And then give constraint for the UIview to the
UIViewcontroller
然后将UIview的约束赋予
UIViewcontroller
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.