2011-03-09 47 views

回答

5

您必須在那裏創建並添加這些標籤。像這樣的東西(警告:未經測試)

UIScrollView * content = [[UIScrollView alloc] initWithFrame:self.view.bounds]; 
[content setContentSize:CGSizeMake(width, height)]; 
//Here you can add those labels to content view 
[self.view addSubView:content]; 

若要滾動工作,你必須指定的內容(setContentSize:)比主視圖大小的尺寸。不要忘記釋放滾動視圖。

+0

我有我已經創建了全光照程序XIB文件一個UIViewController。現在我已經把一個滾動視圖使用IB和所有這些標籤。 – Maulik 2011-03-09 08:44:17

+0

您可以隨意添加標籤。關鍵是將UIScrollView添加到您的控制器的視圖中,並將其內容大小設置爲大於主視圖。 – 2011-03-09 09:25:10

+0

secondView = [[SecondView alloc] initWithNibName:@「second」bundle:nil]; \t // myScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; \t // [myScrollView setContentSize:CGSizeMake(400,600)]; \t \t //[secondView.view addSubview:myScrollView]; \t [self.navigationController pushViewController:secondView animated:YES]; 仍然沒有工作... – Maulik 2011-03-09 09:27:58

0

最簡單的方法:

-(void)scrollview 
{ 
    UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(10, 10, 250, 150)]; 
    scrollview.showsVerticalScrollIndicator=YES; 
    scrollview.scrollEnabled=YES; 
    scrollview.userInteractionEnabled=YES; 
    scrollview.backgroundColor = [UIColor greenColor]; 
    [mainScrollView addSubview:scrollview]; 
    scrollview.contentSize = CGSizeMake(250,150); 
} 
在我的情況