make UIScrollview scroll
I have porblem that my UIScrollView
does not scroll I don't think that is a problem with iphone emulator. Here is my way to construct UI开发者_StackOverflow中文版ScrollView
:
[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 UILabel
to it, to which later I add some info from xml.
labeL = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 1000)];
labeL.numberOfLines = 0;
labeL.text =@"";
[scrollView addSubview:labeL];
this is how I add 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 is like this:
12.1.2010...
and it does not scroll. Why? What I missing?
I think your issue is with setting the size of the scroll view which needs to be larger than the size of the iphone (i.e. it needs to know that there is some area outside the phone display to scroll to). Something along these lines:
UIScrollView *tempScrollView=(UIScrollView *)self.view;
tempScrollView.contentSize=CGSizeMake(800,800);
That should be all you need to make it scroll.
Cheers
James
精彩评论