Eric Chuang
Eric Chuang

Reputation: 1017

UIScrollView not scrolling properly.

I have a uiscrollview dragged onto the storyboard that is 320x570.

In my viewDidLoad, I have added in

self.scrollView.delegate = self;   
self.scrollView.userInteractionEnabled = YES;
self.scrollView.contentSize = self.view.frame.size;

Now when I run the app on the iPhone 5 simulator, my view scrolls but not to the very bottom. When I run the app on the iPhone 4 (smaller screen), it does not scroll at all. What determines how far the scroll should go?

Upvotes: 1

Views: 660

Answers (1)

Oleg Gordiichuk
Oleg Gordiichuk

Reputation: 15512

self.scrollView.contentSize must be more than self.view.frame.size to scroll.

Small example for you:

(X is extra place that must be scrollable to see in small screens.)

[self.scrollView setContentSize:CGSizeMake(self.view.frame.size.width, self.view.frame.size.height + x)];

In you're case you set height of content same as you're main view so no scroll will be applied.

Upvotes: 3

Related Questions