Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIScrollView not showing scroll indicator

I have a UIScrollView which I create and size dynamically using...

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width , length); 

I then add subviews to the UIScrollView. I do have scrollView.showsVerticalScrollIndicator = YES;

When scrolling the scroll indicator never appears.

Even if I call [scrollView flashScrollIndicators] nothing happens.

Ideas?

like image 676
George Avatar asked Jan 07 '10 02:01

George


2 Answers

Had the same problem and couldn't find the cause. The last answer gave the final hint: whenever I added new subviews I first removed all existing subviews from the scrollview (and apparently also the scroll indicators).

After checking in my loop, if the subview really was of the kind I wanted to be removed the scroll indicators showed up:

for (NSObject * subview in [[[scrollView subviews] copy] autorelease]) {     if ([subview isKindOfClass:[MySubView class]]) {        [(MySubView*)subview removeFromSuperview];     } }    

Update: changed code to Nikolai's suggestion

like image 70
Pegolon Avatar answered Sep 20 '22 07:09

Pegolon


When I've dealt with this before, in my implementation of a grid, I would occasionally get some cells over the top of the scroll indicator. To fix this I am now inserting subviews at index 0 rather than adding them, which adds them to the top. So try something like this:

[scrollview insertSubview:subview atIndex:0];

like image 44
Daniel Tull Avatar answered Sep 18 '22 07:09

Daniel Tull