简体   繁体   English

将子视图添加到视图控制器时,ScrollView不滚动

[英]ScrollView doesn't scroll when added a subview to a view controller

I have a ViewController1 which has a ScrollView . 我有一个ViewController1 ,它具有ScrollView In that Scrollview , I am adding another ViewController2 . 在该Scrollview ,我添加了另一个ViewController2 Everything is working fine as expected. 一切都按预期进行。 I could able to scroll the view. 我可以滚动视图。 Here in this ViewController2 , I am trying to add subview another view with separate view class initialising frame from ViewController2 . 在此ViewController2 ,我试图使用与ViewController2分开的视图类初始化框架向另一个视图添加子视图。 When I add this, everything is visible and working fine but the view doesn't allow the scrollview to scroll. 当我添加它时,一切都可见并且可以正常工作,但是视图不允许滚动视图滚动。

The hierarchy is like this 层次结构是这样的

UIViewController1(Root) --> UIScrollView UIViewController1(Root)-> UIScrollView

UIScrollView's subview --> UIViewController2 UIScrollView的子视图-> UIViewController2

UIViewController2's subview --> UIView(separate class frame sent from UIViewController2) UIViewController2的子视图-> UIView(从UIViewController2发送的单独的类框架)

Please help me on this. 请帮我。

Are you sure that you are setting frames properly? 确定要正确设置框架吗? Make sure that nothing is overlapping that scrollView, you can also check whether a contentSize of that scrollView requires scrolling. 确保scrollView没有重叠的部分,您还可以检查该scrollViewcontentSize是否需要滚动。 Those are the things I would start looking at your problem's description. 这些就是我将开始研究您的问题描述的东西。

With overlapping layers you can check it on simulator ( Debug option and then set Color Blended Layers ) 对于重叠的图层,您可以在模拟器上进行检查(“ Debug选项,然后设置“ Color Blended Layers

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

相关问题 ScrollView有子视图时不滚动 - ScrollView doesn't scroll when it has a subview 当主视图控制器的子视图时,tableview将不会滚动 - tableview won't scroll when subview of main view controller 当添加为NavigationController视图的子视图时,iOS视图不会显示其任何子视图 - iOS view doesn't display any of it's subviews when added as a subview of NavigationController's view 当contentsize增加时,scrollview中的子视图不会展开 - Subview within the scrollview doesn't expand when contentsize increases 如何与作为滚动视图子视图的水平滚动视图进行交互? - How to interact with a horizontal scrollview that is a subview of a scroll view? iOS:添加子视图后ScrollView不滚动 - iOS: ScrollView doesn't scroll after subviews are added 添加为子视图后,ScrollView将不会滚动 - ScrollView won't scroll after adding as subview 在UIPangesture中滚动视图滚动时调整子视图的大小 - Resize the subview when scrollview scroll in UIPangesture 如果在滚动视图下面有一个视图,则调整滚动视图缩进不起作用 - Adjust scroll view indents doesn't work if there is a view below the scrollview 即使contentSize大于frame并且在设置内容大小之前添加了子视图,scrollView也不起作用 - scrollView doesn't work even though contentSize is larger than frame and subview is added before setting content size
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM