简体   繁体   English

具有自动布局的scrollview表单

[英]scrollview form with autolayout

I'm trying to build a scrollview form in my app. 我正在尝试在我的应用程序中构建一个scrollview表单。 So, there is the EditForm (which is a uiviewcontroller) which contains a scrollview which contains a contentView (uiview), which contains my fields. 因此,有一个EditForm(这是一个uiviewcontroller),其中包含一个滚动视图,该滚动视图包含一个contentView(uiview),其中包含我的字段。

How do I initialize all these views with autolayout ? 如何使用自动布局初始化所有这些视图? To say to the scrollview to take the entire size of the contentView (i'm adding subview on contentView), to the scrollView to be on the uiviewcontroller, and of course, for the scrollView to scroll properly depending of the size of contentView. 要说到scrollview占据整个contentView的大小(我要在contentView上添加子视图),要使scrollView处于uiviewcontroller上,当然,scrollView可以根据contentView的大小正确滚动。

Thanks :) 谢谢 :)

Actually, this is very easy to do so. 实际上,这很容易做到。

I personally like use pure code without any IB in my applications. 我个人喜欢在应用程序中使用没有任何IB的纯代码。 First check this link from Apple. 首先从Apple检查此链接

Basic step is: 基本步骤是:

  1. Make sure all your subviews are translatesAutoresizingMaskIntoConstraints = NO; 确保所有子视图都已平移AutoresizingMaskIntoConstraints = NO;
  2. Add constraints for your views using VFL 使用VFL为视图添加约束

Tips for UIScrollView for AutoLayout - You need to add bottom constraints for your bottom subviews so that scroll view can be scrollable. 用于自动布局的UIScrollView的技巧-您需要为底部子视图添加底部约束,以便滚动视图可滚动。

Good Luck : ) 祝好运 : )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM