如何在 Xcode5 中使用 AutoLayout 制作 ScrollView [英] How to make a ScrollView with AutoLayout in Xcode5

查看:17
本文介绍了如何在 Xcode5 中使用 AutoLayout 制作 ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用情节提要的 xcode 5 中,如何在启用自动布局的情况下制作一个完全可操作的垂直滚动滚动视图?
考虑到子视图有层次结构:

In xcode 5 using storyboards how would one make a fully operational vertical scrolling scrollview, with AutoLayout ON?
Considering the subviews have hierarchy:

  1.UIView  
    2.UIScrollView
      3.UIView (lets call this UIDetailView to make things easier)

请从代码到约束具体到任何视图是否必须更小等.

Please be specific from code to constraints to wether any of the views HAS to be smaller etc.

推荐答案

这篇博文详细介绍了如何使用 UIScrollView 和 Autolayout ON,使用纯自动布局方法.请注意,博客文章中的所有约束都是通过情节提要定义的.

This blog post details how to use a UIScrollView with Autolayout ON, using a pure autolayout approach. Note though that all constraints in the blog post are defined through the Storyboard.

帖子中的方法假定以下层次结构:

The approach in the post assumes the following hierarchy:

1. View (main view of my UIViewController)
  2. Scroll View (UIScrollView)
     3. Container View (UIView)
       4. Content View (e.g. UIImageView)

我猜容器视图将是您的 UIDetailView,而内容视图将是您的 UIDetailView 中的任何 UIView.

I guess the Container View will be your UIDetailView, and the Content View will be any UIView inside your UIDetailView.

https://happyteamlabs.com/blog/ios-how-to-use-uiscrollview-with-auto-layout-pure-auto-layout/

这篇关于如何在 Xcode5 中使用 AutoLayout 制作 ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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