使UIScrollview滚动
问题描述:
我有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...
和它不滚动。为什么?我错过了什么?
答
我认为你的问题是设置滚动视图的大小需要大于iPhone的大小(即它需要知道在电话显示器外面有一些区域要滚动到)。沿着这些线路 东西:
UIScrollView *tempScrollView=(UIScrollView *)self.view;
tempScrollView.contentSize=CGSizeMake(800,800);
这应该是所有你需要使它滚动。
干杯
詹姆斯
感谢它开始scroll.Your的答案是正确的,但现在它不会滚动我所有的UILabel这是CGRectMake(0,0,320,1000)都有它CGSizeMake东西(600,400)? – Csabi 2011-01-14 09:28:01