Add a UIScrollView programmatically is very simple:
1 2 |
UIScrollView *sView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; [self.view addSubview:sView]; |
In the second part, we give the size of the scroll:
1 2 |
CGSize sViewContentSize = CGSizeMake(640, 460); [sView setContentSize:sViewContentSize]; |
This CGSizeMake(640, 460), means that our scrollview scrolls vertically up to 640px.
So the only thing to do is to calculate how much we want to scroll, in setContentSize.