UIScrollView cannot see ScrollBars / Indicators.

I programmatically created a UISCrollView, but I don't see the scroll bars / indicators.

UIScrollView * contentScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(760, 70, 205, 320)];
contentScrollView.delegate = self;
contentScrollView.scrollEnabled = YES;
contentScrollView.pagingEnabled = YES;
contentScrollView.userInteractionEnabled=YES;
contentScrollView.scrollsToTop = YES;
contentScrollView.showsVerticalScrollIndicator = NO;
contentScrollView.showsVerticalScrollIndicator = YES;
contentScrollView.alwaysBounceVertical = NO;
contentScrollView.alwaysBounceHorizontal = NO;
contentScrollView.bounces = NO;
contentScrollView.hidden = NO;
[contentScrollView flashScrollIndicators];
UILabel *titleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 205, 40)];
UILabel *subtitleLable = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 205, 50)];
UITextView * mainContent = [[UITextView alloc]initWithFrame:CGRectMake(10, 110, 205, 230)];

[titleLable setText:@"...."];
[subtitleLable setText:@"SUbtitle"];
[mainContent setText:@"Descritpon"];
[contentScrollView addSubview:mainContent];
[contentScrollView addSubview:titleLable];
[contentScrollView addSubview:subtitleLable];

I am adding this code to a view that is again tied to another wider scroll view. Does anyone know why this is so? Also, for simplicity, I reduced the text, each of which contains words, but in the program I have enough text to scroll

Thank..

+5
source share
2 answers

To view the scroll for scrolling, the size of the content for scrolling must be larger than its border. Add this line and then check:

contentScrollView.contentSize=CGSizeMake(320, 250);

contentScrollView.bounces YES contentScrollView.showsVerticalScrollIndicator=YES, NO, YES.

.

+2
contentScrollView.showsHorizontalScrollIndicator = YES;
contentScrollView.showsVerticalScrollIndicator = YES;
0

All Articles