TaylorAllred
TaylorAllred

Reputation: 1231

Is there a way to create a usable scrollbar for a native IOS app?

I have been looking around stackoverflow and google trying to find this answer, I can't seem to find anything saying yes or no on it.

I have an app that has roughly 90,000 cells in a single view and scrolling through with swipe gestures works but is abysmally slow as you would think.

Now, there is a search function implemented that rapidly speeds up searching but the client would also like to add a clickable scrollbar like you see in regular web browsers. This app is made on both IOS and Android, the Android version was able to implement a scrollbar, and while I don't think it is necessary to have one, what the client wants, the client gets (if of course it is possible).

Is there a way to implement a scrollbar that would fit on the edge of the screen that is useable to rapidly scroll through literally thousands of cells of content?

Upvotes: 1

Views: 112

Answers (1)

Thyraz
Thyraz

Reputation: 2432

I would simply use an UISlider and rotate it by 90 degrees:

CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI*0.5);
scrollSlider.transform = transform;

Then use your own image for a more scrollbar like look (empty images as background and a different shaped thumb image) using this functions:

- setMaximumTrackImage:forState:
– setMinimumTrackImage:forState:
– setThumbImage:forState:

After that you can use the value property of the slider to adjust the scroll position.

edit: You should hide the real scrollbar in this case and update the slider's value when the view was scrolled by the user using

-scrollViewDidScroll:

To get the math a little bit easier, you could set the min value of the slider to 0, and the max value to scrollView.contentSize.height - scrollView.size.height.

slider.value can be used directly as scrollView.contentOffset that way.

Upvotes: 2

Related Questions