2011-01-14 119 views
3

我有porblem,我的UIScrollView不滾動我不認爲這是iphone模擬器的問題。這是我的方式來構建UIScrollView使UIScrollview滾動

[scrollView setBackgroundColor:[UIColor blackColor]]; 
[scrollView setCanCancelContentTouches:NO]; 
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; 
scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview 
scrollView.scrollEnabled = YES; 

,我添加UILabel到它,後來我加從XML一些信息。

labeL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 1000)]; 
labeL.numberOfLines = 0; 
labeL.text [email protected]""; 
[scrollView addSubview:labeL]; 

我這是怎麼增值UILabel

vypisObratString = [[NSMutableString alloc] initWithString:labeL.text]; 
if (turnOver) { 
    turnOver = NO; 
    [vypisObratString appendString:@"----------------"]; 
    [vypisObratString appendString:@"\n"]; 
    labeL.text = vypisObratString; 
} 

但是,當我編譯程序寫入的corect值,但最後一行是這樣的:

12.1.2010... 

和它不滾動。爲什麼?我錯過了什麼?

回答

10

我認爲你的問題是設置滾動視圖的大小需要大於iPhone的大小(即它需要知道在電話顯示器外面有一些區域要滾動到)。沿着這些線路 東西:

UIScrollView *tempScrollView=(UIScrollView *)self.view; 
tempScrollView.contentSize=CGSizeMake(800,800); 

這應該是所有你需要使它滾動。

乾杯

詹姆斯

+0

感謝它開始scroll.Your的答案是正確的,但現在它不會滾動我所有的UILabel這是CGRectMake(0,0,320,1000)都有它CGSizeMake東西(600,400)? – Csabi 2011-01-14 09:28:01