[英]ScrollView only scroll when I change the rotation of Simulator in ios
I have spend 1 hour but till not find the solution why this happen. 我花了1个小时,但是直到找不到解决方案的原因。
I am setting ContentView
inside my ScrollView
and ContentView
have a Button
at the End. 我在
ScrollView
内设置ContentView
, ContentView
的末尾有一个Button
。 But When I run the project. 但是当我运行项目时。 The ScrollView not scroll.
ScrollView无法滚动。 But When I rotate the Simulator and Again check then it's work.
但是,当我旋转模拟器并再次检查后,它就可以工作了。
What is happening can anyone tell me why this happening. 任何人都可以告诉我为什么会这样。
Code : 代码:
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
AutomaticallyAdjustsScrollViewInsets = false;
scrollView.ContentSize = ContainerView.Bounds.Size;
scrollView.LayoutIfNeeded();
}
I am new to iOS and Xamarin. 我是iOS和Xamarin的新手。
Any help be Appreciated. 任何帮助将不胜感激。
I haven't worked with Xamarin, but after setting contentSize to its superview bounds.size it shouldn't be scrolling at all. 我没有使用Xamarin,但是在将contentSize设置为其超级视图bounds.size之后,它根本不应该滚动。 The thing is, it is only scrolling when it need to and you set its size exactly the same, as it is already.
事实是,它仅在需要时才滚动,并且您将其大小设置为已经完全相同。
So, if I got it correctly, and ContainerView is the superview of scrollView and ContentView is the subview of it, you have to use something like 因此,如果我正确理解它,并且ContainerView是scrollView的父视图,而ContentView是它的子视图,则必须使用类似
scrollView.ContentSize = ContentView.Bounds.Size;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.