使UIScrollview滚动

Csa*_*abi 3 xcode objective-c uiscrollview uilabel

我有问题,我UIScrollView不滚动我不认为这是iphone模拟器的问题.这是我的构建方式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;
Run Code Online (Sandbox Code Playgroud)

然后我添加UILabel它,后来我从xml中添加了一些信息.

labeL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 1000)];
labeL.numberOfLines = 0;
labeL.text =@"";
[scrollView addSubview:labeL];
Run Code Online (Sandbox Code Playgroud)

这是我如何增加价值UILabel:

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

但是当我编译程序时,它会写入corect值,但最后一行是这样的:

12.1.2010...
Run Code Online (Sandbox Code Playgroud)

而且它不会滚动.为什么?我错过了什么?

Jam*_*eld 10

我认为你的问题是设置滚动视图的大小需要大于iPhone的大小(即它需要知道手机显示屏外有一些区域滚动).这些方面的东西:

UIScrollView *tempScrollView=(UIScrollView *)self.view;
tempScrollView.contentSize=CGSizeMake(800,800);
Run Code Online (Sandbox Code Playgroud)

这应该是你需要滚动的全部内容.

干杯

詹姆士