2013-02-15 104 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

相关问题