Scroll UIScrollview

I have an emblem that mine UIScrollViewdoes not scroll. I do not think this is a problem with the iphone emulator. Here is my way to build 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;

and I add to it UILabel, to which later I add some information from xml.

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

this is how i add the value to UILabel:

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

But when I compile the program, it writes the corect values, but the last line looks like this:

12.1.2010...

and it does not scroll. What for? What am I missing?

+3
source share
1 answer

I think your problem is with setting the scroll size, which should be larger than the iphone size (i.e., it should know that there is some area outside the phone screen to scroll). Something like that:

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

, .

+10

Source: https://habr.com/ru/post/1785385/


All Articles