Can't scroll in UIScrollView as soon as UILabe

2019-04-27 06:32发布

问题:

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: I do set the contentSize of my scrollView, so this cannot be the problem!

回答1:

Move the code in the viewDidAppear function like this

-(void)viewDidAppear:(BOOL)animated{

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

}