UIScrollView 内的 UIVIew 反弹回来 [英] UIVIew inside UIScrollView bounces back

查看:23
本文介绍了UIScrollView 内的 UIVIew 反弹回来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序适用于 iPad,使用带有两个场景的故事板.在一个场景中,我有一个包含 UIVIew 的 UIScrollView.它会滚动,但会立即弹回,使自己变得毫无用处.UIScrollView 的大小为 768x590;UIView 的大小为 768x1590;UIScrollView 的 ContentSize 为 768x590.这是 UIScrollView 设置的图像:

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:

(过去 6 个小时我一直在查看 SO 和 Google,尝试了很多东西,但没有任何效果.我也做过几次 CMD + Option + K(Clean),但这也没有帮助.

(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.

为什么它不能正确滚动?

Why does it not scroll properly?

推荐答案

找到适合我的方法!

当你在 InterfaceBuilder 中将视图嵌入到 UIScrollView 中时,然后有一个自动设置的约束.如果您的视图长"于纵向屏幕,它根本不会滚动.

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.

要让 UIScrollView 在 AutoLayout 中运行,请查看您的约束.

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.

感谢您的帮助...我很感激.

Thanks for your help... I appreciate it.

这篇关于UIScrollView 内的 UIVIew 反弹回来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆