[英]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没有重叠的部分,您还可以检查该
scrollView
的contentSize
是否需要滚动。 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.