2010-02-16 34 views
7

Tôi muốn cuộn nội dung của mình trong UIScrollView. Nhưng tôi nghĩ tôi đã phạm sai lầm.UIScrollView: Cuộn không hoạt động

// 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]; 

Trả lời

7

Thay vì thiết lập khung lớn bạn phải thiết lập kích thước nội dung UIScrollView của:

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

yeah, thanks !!! – fabian

Các vấn đề liên quan