how to set scrollview content size with auto layout?

回眸只為那壹抹淺笑 提交于 2020-01-20 07:43:55

问题


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


回答1:


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

  1. Add a view to your scrollView. This should be the only top level view on your scrollView and it will serve as your contentView.
  2. Constrain the left, top, right, and bottom edges of this contentView to the left, top, right, and bottom of the scrollView with offsets of 0.
  3. To size the contentView, add width and height constraints to the contentView. If you want it to scroll, the width and height must be larger than the width and height of the scrollView itself. If you only want to scroll vertically, set the width of the contentView to be equal to the width of the scrollView.


来源:https://stackoverflow.com/questions/28438830/how-to-set-scrollview-content-size-with-auto-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!