You can set content offset to 2000 if it is more than 2000 so it won't go beyond the bound.
Implement this method and set it to the delegate of that scrollview
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.x > 2000) {
CGPoint offset = scrollView.contentOffset;
offset.x = 2000;
[scrollView setContentOffset:offset animated:YES];
}
}
Edit: I just tried this, and it works fine. Maybe check why setContentSize:
is not working?
Another approach, make a view with heigh of 2000, put your content view inside it, and add that view as subview of scrollview.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 600, 7000)];
label.numberOfLines = 60;
label.font = [UIFont systemFontOfSize:100];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
NSMutableString *str = [[NSMutableString alloc] initWithCapacity:300];
for (int i = 0; i < 60; i++)
[str appendFormat:@"%d\n", i];
label.text = str;
[scrollView addSubview:label];
[scrollView setContentSize:CGSizeMake(600, 2000)];
[self.view addSubview:scrollView];