UIScrollView不会滚动(故事板) [英] UIScrollView won't scroll (Storyboards)

查看:93
本文介绍了UIScrollView不会滚动(故事板)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是故事板的新手;我之前做过一些Interface Builder,并进行了大量的手动UI定位。我已经搜索了这个问题,试过在其他相关帖子中找到的解决方案,但没有用。

I'm new to Storyboards; I've done some Interface Builder before and lots of manual UI positioning. I've searched this issue, tried the solutions found in the other relevant posts, to no avail.

我有一个视图控制器,在Storyboards中添加了UIScrollView。 ScrollView插座已连接,属性已合成。已选中滚动已启用。弹跳被检查。即便如此,也没有迹象表明会进行任何滚动。当我垂直检查Bounces时,我至少可以看到可滚动的内容,但是在我发布后它会反弹回来。我发现的框架尺寸设置为320和521.我尝试了不同的高度,但没有任何帮助。 (什么应该是故事板中设置的尺寸,以适应较旧和较新的手机尺寸?)。

I have a view controller with a UIScrollView added in Storyboards. The ScrollView outlet has been connected, the property synthesized. Scrolling Enabled is checked. Bounces is checked. Even then there was no indication that any scrolling would take place. When I checked Bounces Vertically, I could at least see the scrollable content, but it bounces back after I release. The frame size I found set at 320 and 521. I experimented with different heights but nothing helped. (What ought to be the size set in Storyboards that will accommodate the older and newer phone sizes?).

在viewDidLoad中,我添加了

In viewDidLoad, I added

    [scrollView setContentSize:CGSizeMake(320, 1000)];

之后的日志声明确认此值已被接受。但它也没有帮助。

A log statement afterwards confirms that this value has been accepted. But it didn't help either.

有一篇帖子中有人建议添加:

Someone in one post suggested adding:

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self.scrollView setContentSize:CGSizeMake(320, 808)];
}

当控制器加载时,这会导致程序崩溃。

This had the effect of crashing the program when the controller loaded.

非常感谢任何帮助!

谢谢。

推荐答案

有两件事是必要的:

1)将scrollview的高度设置为480。

1) Set height of scrollview to 480.

2)将约束添加到scrollview中最底部的字段。约束是Pin >> Bottom Space to Superview。

2) Add constraint to the bottommost field in the scrollview. The constraint was Pin >> Bottom Space to Superview.

这篇关于UIScrollView不会滚动(故事板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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