3
votes

EDIT: The crux of this problem is that scroll indicators do not show during programmatic scrolling, but I would like them to. My original question (provided below) assumed this had something to do with userInteractionEnabled, but it does not. The mention of a master and slave UIScrollView is also possibly distracting from my core problem (the need to show scroll indicators during a programmatic scroll). Apologies to those of you who answered or commented based on my misleading assumptions/info.

Possible Solution: The only way I found to do this was to use the fact that scroll indicators are instances of UIImageView and use a category on it to hack the alpha. This article shows the approach. It was then a case of using tags and scroll view delegate methods to turn the alpha permanently on prior to a programmatic scroll, and permanently off when the scroll is finished. This feels hacky though, so any further suggestions would be welcome!

Everything below this line is the original unedited question to provide context to users' answers and comments

Setting userInteractionEnabled in a UIScrollView object to NO appears to disable the scroll indicators upon programmatic scrolling. This happens even if you have self.showsVerticalScrollIndicator = self.showsHorizontalScrollIndicator = YES;

Is there any way to programmatically scroll the scroll view but still show the indicators?

(To provide some context: I have a slave scrollview that mimics a master scrollview by hooking up the scrollview delegate callbacks and passing the content offset to the slave scrollview. However, I don't want the user to be able to directly manipulate the slave scrollview, but I do want scroll indicators).

2
Why do you have this odd setup? (Apologies if it's obvious!) - jrtc27
Because in my app I'd like a slave scrollview that follows a master scrollview, but that can't be interacted with directly. I find it strange that Apple automatically disable the scroll indicators in this case - just because the user can't interact with it doesn't mean it cant be scrolled programatically. - Barjavel
Screenshot/mockup, please? I'm finding it hard to understand why this behaviour would be intended... :/ - jrtc27
What happens when you call [scrollView flashScrollIndicators] whilst it is scrolling? - Tim
Hi @Tim, I tried the approach of calling flashScrollIndicators during the programmatic scroll, but the problem is that the scroll indicators may fade long before the scroll is finished animating. Continuous calls to flashScrollIndicators while the scrolling is happening were no good either, as this lead to flickering of the scroll indicators. - Barjavel

2 Answers

0
votes

Instead of setting userInteractionEnabled to false try setting the UIScrollView's scrollEnabled property to false. The doc. says "When scrolling is disabled, the scroll view does not accept touch events" that should mean that you should still be able to programmatically scroll the UIScrollView. Hope this helps - Did not test it out let me know.

0
votes

You could try putting a transparent UIView (alpha == 0.0) over your scroll view (but as a sibling in the view hierarchy, not as a subview). Set touchesEnabled to YES on the transparent view, and it will intercept touches heading for the scroll view.