I need to make a scrollbar always visible on viewDidLoad so that the user can understand that there is content to scroll. I did the following:
[myscrollView flashScrollIndicators];
But then the scrollbars only appear for some time after viewDidLoad and disappear again only to reappear when the user touches the screen..
I need to make scrollbars always visible. How can I do it?
I want to offer my solution. I don't like the most popular variant with category (overriding methods in category can be the reason of some indetermination what method should be called in runtime, since there is two methods with the same selector). I use swizzling instead. And also I don't need to use tags.
Add this method to your view controller, where you have scroll view (
self.categoriesTableView
in my case)Add new class
The scroll indicator (vertical scroll indicator in this case) will be always at the screen.
Apple indirectly discourage constantly displaying scroll indicators in their iOS Human Interface Guidelines but guidelines are just guidelines for a reason, they don't account for every scenario and sometimes you may need to politely ignore them.
The scroll indicators of any content views are
UIImageView
subviews of those content views. This means you can access the scroll indicators of aUIScrollView
as you would any of its other subviews (i.e.myScrollView.subviews
) and modify the scroll indicators as you would anyUIImageView
(e.g.scrollIndicatorImageView.backgroundColor = [UIColor redColor];
).The most popular solution appears to be the following code:
Which is originally credited to this source.
This defines a category for
UIImageView
that defines a custom setter for the alpha property. This works because at some point in the underlying code for theUIScrollView
, it will set its scroll indicator's alpha property to 0 in order to hide it. At this point it will run through our category and, if the hostingUIScrollView
has the right tag, it will ignore the value being set, leaving it displayed.In order to use this solution ensure your
UIScrollView
has the appropriate tag e.g.If you want to display the scroll indicator from the moment its
UIScrollView
is visible simply flash the scroll indicators when the view appears .e.gAdditional SO references:
I dont know whether this will work or not. But just a hint for you.
Scrollbar inside the Scrollview is a Imageview. Which is a subview of UIScrollview
So get the Scrollbar Imageview of the UIscrollview. Then try to set that image property hidden to NO or Change Alpha value
Got reference from here