无法在故事板中添加 UILabel/其他子视图后立即在 UIScrollView 中滚动 [英] Can't scroll in UIScrollView as soon as UILabel / other subview added in Storyboard

查看:68
本文介绍了无法在故事板中添加 UILabel/其他子视图后立即在 UIScrollView 中滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下问题:一旦我添加例如一个 UILabel 到我的 UIScrollView - 使用故事板 - 滚动视图停止工作"(我的意思是你根本无法滚动).然而,以编程方式添加子视图滚动视图工作正常,但由于我更喜欢​​使用故事板直观地设计我的应用程序,我想解决这个神秘的错误.

I encountered the following problem: as soon as I add e.g. a UILabel to my UIScrollView - using the storyboard - the scroll view stops "working" (with that I mean you cannot scroll at all). However adding a subview programmatically the scroll view works fine but since I prefer designing my apps visually with storyboard I would like to solve this mysterious error.

有谁知道为什么会发生这个错误?提前致谢:)

Does anyone knows why this error is occurring? Thanks in advance :)

PS:我确实设置了 scrollView 的 contentSize,所以这不是问题!

PS: I do set the contentSize of my scrollView, so this cannot be the problem!

推荐答案

把viewDidAppear函数中的代码像这样移动

Move the code in the viewDidAppear function like this

-(void)viewDidAppear:(BOOL)动画{

-(void)viewDidAppear:(BOOL)animated{

[super viewDidAppear:animated];
self.scrollView.contentSize = CGSizeMake(500.f, 500.f);

}

这篇关于无法在故事板中添加 UILabel/其他子视图后立即在 UIScrollView 中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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