Discussion:
UiView as slider with inertia
(too old to reply)
Eric Dolecki
2018-10-01 03:46:07 UTC
Permalink
I've been tasked with coming up with a few horizontal sliders that are really sequential numbers with the selected value in the middle of the screen. They want drag and release with inertia and also rubber banding on the ends. Values snap into place. 0 1 2 3 4 5 ...

Does anyone have something like this to save me some time? I'm assuming uipangesturerecognizer and some uikit dynamics.

Thanks!!
Eric

Sent from my iPhone X.
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.net
Jonathan Hull
2018-10-01 06:34:46 UTC
Permalink
What you want is UICollectionView. Make the numbers your cells, and use -targetContentOffset(forProposedContentOffset:, withScrollingVelocity:) to provide the snapping behavior.
Post by Eric Dolecki
I've been tasked with coming up with a few horizontal sliders that are really sequential numbers with the selected value in the middle of the screen. They want drag and release with inertia and also rubber banding on the ends. Values snap into place. 0 1 2 3 4 5 ...
Does anyone have something like this to save me some time? I'm assuming uipangesturerecognizer and some uikit dynamics.
Thanks!!
Eric
Sent from my iPhone X.
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.net
Eric E. Dolecki
2018-10-01 10:38:46 UTC
Permalink
Have an example? Sounds interesting - but I need the control to work like a
UIScrollView in a way (the content can go off to the left and right and not
flow)

| visible |
| |
0 1 2 | 3 4 *5* 6 7 | 8 9
| |
Post by Jonathan Hull
What you want is UICollectionView. Make the numbers your cells, and use
-targetContentOffset(forProposedContentOffset:, withScrollingVelocity:) to
provide the snapping behavior.
Post by Eric Dolecki
I've been tasked with coming up with a few horizontal sliders that are
really sequential numbers with the selected value in the middle of the
screen. They want drag and release with inertia and also rubber banding on
the ends. Values snap into place. 0 1 2 3 4 5 ...
Post by Eric Dolecki
Does anyone have something like this to save me some time? I'm assuming
uipangesturerecognizer and some uikit dynamics.
Post by Eric Dolecki
Thanks!!
Eric
Sent from my iPhone X.
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive.net

This email sent to ***@ml-in.narkive.net
David Duncan
2018-10-01 20:08:13 UTC
Permalink
Yea, Jonathan’s recommendation is probably best. You would configure the collection view to scroll horizontally and just vend cells that are the numbers. You can probably configure UICollectionViewFlowLayout to do most of the heavy lifting for you, and perhaps just do a subclass to override targetContentOffset: as Jonathan recommended.

And if you end up needing more customization, constructing a UICollectionViewLayout subclass for this should be similarly straightforward, if you really need to, but I suspect subclassing will be easiest.
Post by Eric E. Dolecki
Have an example? Sounds interesting - but I need the control to work like a
UIScrollView in a way (the content can go off to the left and right and not
flow)
| visible |
| |
0 1 2 | 3 4 *5* 6 7 | 8 9
| |
Post by Jonathan Hull
What you want is UICollectionView. Make the numbers your cells, and use
-targetContentOffset(forProposedContentOffset:, withScrollingVelocity:) to
provide the snapping behavior.
Post by Eric Dolecki
I've been tasked with coming up with a few horizontal sliders that are
really sequential numbers with the selected value in the middle of the
screen. They want drag and release with inertia and also rubber banding on
the ends. Values snap into place. 0 1 2 3 4 5 ...
Post by Eric Dolecki
Does anyone have something like this to save me some time? I'm assuming
uipangesturerecognizer and some uikit dynamics.
Post by Eric Dolecki
Thanks!!
Eric
Sent from my iPhone X.
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
_______________________________________________
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/gegs%40ml-in.narkive
Loading...