【问题标题】:Strange behaviour of UIScrollView in XCODE 8 without autolayout没有自动布局的 XCODE 8 中 UIScrollView 的奇怪行为
【发布时间】:2016-09-15 12:37:58
【问题描述】:

我刚刚将我的 xcode 从 7.3 更新到 8,并面临所有 UISrollviews 的一些奇怪行为。在滚动视图内的设备子视图中进行测试时,滚动视图与屏幕中心对齐,但在情节提要中排列得非常好。我对这种意外行为没有任何线索。请帮忙..

【问题讨论】:

  • 请提供更多关于你目前已经完成的信息:stackoverflow.com/help/how-to-ask
  • 使用 Autolayout 就可以正常工作了
  • 我在 xcode8 中遇到了同样的问题 Scrollview 没有自动布局
  • 我需要让整个故事板自动布局吗?还是只有特定的滚动视图?

标签: swift uiscrollview xcode8


【解决方案1】:

您必须在滚动视图中添加一个名为 (scrollContainerVw) 的子视图并设置以下引脚: 滚动视图和子视图。

如果你想支持多屏请在视图中添加以下代码:

    self.scrollVw.frame.size.width = self.view.frame.size.width
    self.scrollVw.frame.size.height = self.view.frame.size.height
    self.scrollContainerVw.frame.size.width = self.view.frame.size.width
    self.scrollContainerVw.frame.size.height = self.view.frame.size.height

【讨论】:

    猜你喜欢
    • 2013-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    相关资源
    最近更新 更多