1
votes

I'm testing with a UIScrollView and placed a UILabel inside of it. The point is I'm trying to scroll to the bottom to read the whole UIlabel but as soon as I stop dragging up the scroll view returns down (Rubber band effect) and i'm not able to read the last three lines of text.

scrollView.backgroundColor = [UIColor redColor];
scrollView.contentSize = CGSizeMake(320, 600);



UILabel *lbltestScroll = [[UILabel alloc]initWithFrame:CGRectMake(0,100,320,600)];

lbltestScroll.text =@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.";

lbltestScroll.lineBreakMode = UILineBreakModeWordWrap; 
lbltestScroll.numberOfLines = 0;

[scrollView addSubview:lbltestScroll];

Where is the problem?

Thanks Luca

1

1 Answers

-1
votes

The contentSize of the scroll view is too small.

Since the label is the same size as the content size of your scroll view, but it is positioned at 0, 100 it wont fit in the available space inside the scroll view. The contentSize property has nothing to do with the actual size of the scroll view (the "window" that you are looking through), but instead sets the size of the "canvas" that is available to display content, and more or less how far you can scroll.