adit
adit

Reputation: 33674

UIScrollView won't scroll

I have tried the following:

contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 600, 400)];
[contentScrollView setContentSize:CGSizeMake(600, 400)];
[contentScrollView addSubview:twitterSigninViewController.view];
[contentScrollView setScrollEnabled:YES];

However, this doesn't scroll. Why is this?

Upvotes: 1

Views: 4370

Answers (3)

AAV
AAV

Reputation: 3813

Simple answer to your question change setContentSize: line to:

[contentScrollView setContentSize:CGSizeMake(600.0, 481.0)];

Upvotes: 3

Ryan Crews
Ryan Crews

Reputation: 3033

The issue is the frame size (how large the actual view is) is the same as your content size (how large your content is). So if you make your frame's height less than your contentSize's height it will scroll.

Upvotes: 4

Lily Ballard
Lily Ballard

Reputation: 185821

It doesn't scroll because there's nothing to scroll. You told it your content size was exactly the same size as the scrollview itself, so it's already displaying everything. You can set the alwaysBounceHorizontal or alwaysBounceVertical properties if you want it to always bounce when trying to scroll, but that's about it.

Upvotes: 8

Related Questions