xcode UIScrollView 内的 UIVIew 反弹回来
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13317829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIVIew inside UIScrollView bounces back
提问by SpokaneDude
MY app is for iPad using Storyboards with two scenes. On one scene, I have a UIScrollView that contains a UIVIew. It scrolls, but bounces back immediately, rendering itself useless. The size of the UIScrollView is 768x590; the size of the UIView is 768x1590; ContentSize of the UIScrollView is 768x590. This is an image of the UIScrollView settings:
我的应用程序适用于 iPad,使用带有两个场景的故事板。在一个场景中,我有一个包含 UIVIew 的 UIScrollView。它会滚动,但会立即弹回,使自身变得毫无用处。UIScrollView 的大小为 768x590;UIView 的大小为 768x1590;UIScrollView 的 ContentSize 为 768x590。这是 UIScrollView 设置的图像:
(I have looked at SO and Google for the past 6 hours, tried a lot of stuff, but nothing works. I have also done a CMD + Option + K (Clean) several times, and that didn't help either.
(在过去的 6 个小时里,我查看了 SO 和 Google,尝试了很多东西,但没有任何效果。我还多次执行了 CMD + Option + K(清洁),但这也没有帮助。
Why does it not scroll properly?
为什么它不能正确滚动?
回答by SpokaneDude
Found what works for me!
找到对我有用的东西!
When you embed a view into a UIScrollView in InterfaceBuilder, then there's a constraint automatically set. If your view is "longer" than the screen in portrait, it wont scroll at all.
But if you rotate the screen, you'll notice the ability to scroll a little.
To get UIScrollView going in AutoLayout look into your constraints.
Find "Vertical Space - Scroll View - View" and set it from "constant" to "auto" - fixed everything for me.
当您将视图嵌入到 InterfaceBuilder 的 UIScrollView 中时,会自动设置一个约束。如果您的视图比纵向屏幕“长”,则它根本不会滚动。
但是,如果您旋转屏幕,您会注意到可以稍微滚动一下。
要让 UIScrollView 在 AutoLayout 中运行,请查看您的约束。
找到“垂直空间 - 滚动视图 - 视图”并将其从“常量”设置为“自动” - 为我修复了所有问题。
Thanks for your help... I appreciate it.
感谢您的帮助...我很感激。
回答by spider1983
Your scrollView height is less than the uiview which is the subview in your case of scrollview and for scrolling it fully you will have to set your scrollview contentSize heightmore than the height of the view you are scrolling in it,please give a check on this point.
您的 scrollView 高度小于 uiview ,这是您在 scrollview 的情况下的子视图,并且要完全滚动它,您必须将scrollview contentSize 高度设置为 大于您在其中滚动的视图的高度,请检查一下观点。