UIScrollView not working – scrolling doesn’t work
Nov.18, 2008 in
Development, iPhone Development, iphone
Okay, so I’ve just spent the last few hours trying to work out why my UIScrollView won’t scroll! The secret, I’ve found, is the following:
- (void)viewDidLoad {
[super viewDidLoad];
// Setup scroll view
[scrollView
setContentSize:CGSizeMake(backgroundImage.frame.size.width,
backgroundImage.frame.size.height+200)];
}
You must call setContentSize and pass it an object which has a greater size than the ScrollView itself. Also, you need to do this after the view has loaded (so use viewDidLoad). In my example I was using a UIScrollView to allow me to scroll an image, which is a sub-view of the UIScrollView (all setup in IB).
Tags: iphone, iPhone Development

Leave a Reply