UIScrollView: scrolling does not work

I would like to scroll my content in a UIScrollView. But I think I was wrong.

// setup view CGRect appFrame = [UIScreen mainScreen].applicationFrame; CGRect frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height); self.view = [[[UIView alloc] initWithFrame:frame] autorelease]; // setup wrapper UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, appFrame.size.width, appFrame.size.height + 320)]; wrapper.backgroundColor = [UIColor redColor]; wrapper.scrollEnabled = YES; [self.view addSubview:wrapper]; // title (simple version here) title.text = "Hello World"; [wrapper addSubview:title]; 
+7
iphone uiscrollview
source share
1 answer

Instead of setting a large frame, you should set the size of the contents of the UIScrollView:

 UIScrollView *wrapper = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, appFrame.size.width, appFrame.size.height)]; wrapper.contentSize =CGSizeMake(appFrame.size.width, appFrame.size.height + 320); 
+7
source share

All Articles