简体   繁体   English

iOS:情节提要中的Scrollview无法与嵌入式容器视图一起滚动

[英]iOS: Scrollview in storyboard won't scroll with embedded container views

I have a series of container views inside one scroll view. 我在一个滚动视图中有一系列容器视图。 Currently, the view controller does not scroll vertically. 当前,视图控制器不能垂直滚动。 Can a scroll view detect scroll touches through container view controllers? 滚动视图可以通过容器视图控制器检测滚动触摸吗?

滚动视图

I see you aren't using any autolayout constraints, maybe that's the issue. 我看到您没有使用任何自动布局约束,也许就是这个问题。

If you set the contentSize in viewDidLoad: it will get changed when the scrollView hits layoutSubviews . 如果您在viewDidLoad:设置contentSize viewDidLoad:当scrollView命中layoutSubviews时,它将被更改。

UIScrollViews need all their contentSize information to match in order to work properly. UIScrollViews需要所有其contentSize信息进行匹配才能正常工作。 Autolayout affects that property. 自动布局会影响该属性。 You will need constraints that go ALL the way from the top to the bottom and from the left to the right of the scroll view even if IB is not asking for it. 您将需要从滚动视图的顶部到底部以及从左侧到右侧的所有约束,即使IB不要求它。

Autolayout manipulation in XCode 6 has some VERY welcome improvements. XCode 6中的自动布局操作有一些非常令人欢迎的改进。 I recommend updating. 我建议更新。 I've been using it for the last couple weeks on mavericks and so far so good. 在过去的几周里,我一直在用特立独行的方式使用它,到目前为止效果很好。

Cheers! 干杯!

You could always pass the touches by subclassing the container view. 您总是可以通过对容器视图进行子类化来传递相关信息。 There you can call the parent view controllers respective methods 在那里,您可以分别调用父视图控制器的方法

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.parentViewController touchesBegan:touches withEvent:event];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM