【问题标题】:Center a fixed UIView inside a UIScrollView with AutoLayout使用 AutoLayout 在 UIScrollView 中居中固定 UIView
【发布时间】:2016-08-20 10:49:11
【问题描述】:

我了解UIScrollViewAutoLayout 的操作,但是在我在互联网上看到的所有情况下,我都没有发现类似的问题,也许这就是解决方案不起作用的原因正确。

我的情况是这样的:

Scroll View
   Content View
      Login View

登录视图我需要一个固定的宽度/高度,垂直和水平居中。这里是我设置的约束:

问题是:当我将模拟器(iPhone 6s)旋转到横向时,我无法滚动查看所有内容,因为滚动视图的内容大小为 375,而我的登录框高度为 420。

对于这种特殊情况,我有什么遗漏吗?

【问题讨论】:

    标签: ios xcode uiscrollview autolayout


    【解决方案1】:

    你的约束应该是这样的,

    ScrollView - top,bottom,leading,trailing

    ContentView (UIView) - top,bottom,leading,trailing,fixed height,horizontally center in container(center X)

    LoginView - fixed width,fixed height, horizontally center in container(center X) and vertically center in container (center Y)

    【讨论】:

      【解决方案2】:

      试试我为您创建的这个小视频教程。它展示了如何设置适用于任何ios devicescrollview + 适用于任何orientation 模式。教程写在objective c,但没关系概念是一样的。更少的编码,只有一个method + autolayout.

      视频教程链接--->setup scrollview for any ios device + for any orientation mode in ios

      希望这对你有所帮助。试试这个并享受......

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-01
        • 1970-01-01
        相关资源
        最近更新 更多