在将约束应用于UIScrollView时需要帮助 [英] Need Help in applying constraints to UIScrollView

查看:76
本文介绍了在将约束应用于UIScrollView时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以编程方式添加子视图. 要求::添加更多视图后,应启用滚动. 我应用的约束:

I'm adding subviews programmatically. Requirement : when extra views are added the scroll should be enabled. The constraints that I applied :

要删除顶部的多余空格,我写了self.automaticallyAdjustsScrollViewInsets = false 也将内容大小设置为self.scrollView.contentSize = CGSize(width: self.contentView.frame.width, height: self.contentView.frame.height*2)

To remove extra spaces at the top I wrote self.automaticallyAdjustsScrollViewInsets = false also give content size as self.scrollView.contentSize = CGSize(width: self.contentView.frame.width, height: self.contentView.frame.height*2)

但是,加载视图时,滚动被完全禁用.

But the when the view is loaded scroll is completely disabled.

请帮助我

推荐答案

使用自动版式时,必须在 viewcontroller 方法中设置内容大小 覆盖以下方法.

When you using auto layout, you have to set content size at viewcontroller method, you have to override following method.

-(void)viewWillLayoutSubviews;

迅速

override func viewWillLayoutSubviews() {

    }

这篇关于在将约束应用于UIScrollView时需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆