用户登录
用户注册

分享至

如何使用自动布局设置滚动视图内容大小?

  • 作者: 爱好难啊
  • 来源: 51数据库
  • 2022-10-21

问题描述

我有一个屏幕,我在本端视图上添加了 1 个滚动视图.标签栏和导航栏都在那里,iPhone 4 的视图高度为 455.我在滚动视图上添加了更多内容.滚动视图和自身视图的高度相同.但是当我无法为滚动视图设置内容大小时.即使我也设置了它也不起作用.请帮助我.谢谢

I have one screen where I have added 1 scroll view on self view. Tab bar and navigation bar both are there and for iPhone 4 view height is 455.I have added more content on scroll view.the height of scroll view and self view is same.but when i am unable to set content size for scroll view.even i set too it is not working.Please help me. Thanks

推荐答案

下面是如何在 Auto Layout 中设置 contentView 的大小:

Here is how to set up the size of the contentView in Auto Layout:

  1. 为您的滚动视图添加一个视图.这应该是您的 scrollView 上唯一的顶级视图,它将用作您的 contentView.
  2. 将此 contentView 的左、上、右和下边缘约束到 scrollView 的左、上、右和底部,偏移量为 0.
  3. 要调整 contentView 的大小,请向 contentView 添加宽度和高度约束.如果想让它滚动,宽度和高度必须大于scrollView本身的宽度和高度.如果只想垂直滚动,请将 contentView 的宽度设置为等于 scrollView 的宽度.
软件
前端设计
程序设计
Java相关