2013-02-15 64 views
0

我想添加UIScrollView與標籤,並讓它滾動垂直如果我有更多的標籤我添加下面的代碼,但它不滾動。我還有更多5個標籤可供添加。如何添加一個scrollView垂直滾動allong與標籤

在頭文件

IBOutlet UIScrollView*scrollView; 


    @property(nonatomic,retain) IBOutlet UIScrollView*scrollView; 

在實現文件viewDidLoad中

 titleLabel = [[UILabel alloc ] initWithFrame:CGRectMake(892,257,206,84)]; 
titleLabel.textAlignment = UITextAlignmentRight; 
titleLabel.textColor = [UIColor blackColor]; 
titleLabel.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[scrollView addSubview:titleLabel]; 


titleLabel = [[UILabel alloc ] initWithFrame:CGRectMake(10,20,206,84)]; 
titleLabel.textAlignment = UITextAlignmentRight; 
titleLabel.textColor = [UIColor blackColor]; 
titleLabel.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[scrollView addSubview:titleLabel]; 


titleLabel1 = [[UILabel alloc ] initWithFrame:CGRectMake(10,110,206,84)]; 
titleLabel1.textAlignment = UITextAlignmentRight; 
titleLabel1.textColor = [UIColor blackColor]; 
titleLabel1.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[email protected]"tilte Working Fine"; 

[scrollView addSubview:titleLabel1]; 


titleLabel2 = [[UILabel alloc ] initWithFrame:CGRectMake(10,190,206,84)]; 
titleLabel2.textAlignment = UITextAlignmentRight; 
titleLabel2.textColor = [UIColor blackColor]; 
[email protected]"tilte Working Fine"; 
titleLabel2.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[scrollView addSubview:titleLabel2]; 




titleLabel3 = [[UILabel alloc ] initWithFrame:CGRectMake(10,270,206,84)]; 
titleLabel3.textAlignment = UITextAlignmentRight; 
titleLabel3.textColor = [UIColor blackColor]; 
titleLabel3.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[email protected]"tilte Working Fine"; 

[scrollView addSubview:titleLabel3]; 


titleLabel4 = [[UILabel alloc ] initWithFrame:CGRectMake(10,360,206,84)]; 
titleLabel4.textAlignment = UITextAlignmentRight; 
titleLabel4.textColor = [UIColor blackColor]; 
titleLabel4.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[email protected]"tilte Working Fine"; 

[scrollView addSubview:titleLabel4]; 



titleLabel5 = [[UILabel alloc ] initWithFrame:CGRectMake(10,450,206,84)]; 
titleLabel5.textAlignment = UITextAlignmentRight; 
titleLabel5.textColor = [UIColor blackColor]; 
titleLabel5.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[email protected]"tilte Working Fine"; 

[scrollView addSubview:titleLabel5]; 


titleLabel6 = [[UILabel alloc ] initWithFrame:CGRectMake(10,530,206,84)]; 
titleLabel6.textAlignment = UITextAlignmentRight; 
[email protected]"tilte Working Fine"; 

titleLabel6.textColor = [UIColor blackColor]; 
titleLabel6.font = [UIFont fontWithName:@"Helvetica" size:14]; 
[scrollView addSubview:titleLabel6]; 

回答

0

你需要增加滾動的內容大小查看其不同勢從它的幀大小,如果內容大小更多的則是幀大小將滾動。

+0

我沒有得到你在說什麼,可以請你解釋一下或者寫一些代碼 – user1808433 2013-02-15 05:29:24

+1

[scrollview setContentSize :((CGSizeMake(,))]]; – amar 2013-02-15 05:33:55

+0

每當你添加一個新的標籤增加內容大小的高度 – amar 2013-02-15 05:34:27

相關問題