On Jan 22, 2017, at 18:27 , Eric Dolecki <[email protected]> wrote:
> 
> Does anyone have a control (knob) that you can turn with a horizontal swipe, 
> but snaps to detents. It doesn't travel 360 degrees, but you can throw it and 
> it rubber bands at its minimum or maximum detent values. I can't seem to get 
> my head around getting all of it and I'm frustrated. An example range would 
> be 0-15 with 8 degrees between each detent value. So throw, slow turning, 
> both with snapping to avoid value (always an Int).
> The knob will be quite large so the snapping will make sense. 

The snapping behavior seems like an independent problem — once you’ve decided 
where the continuous motion would end, you can apply the snapping decision.

The throwing part probably requires knowing the acceleration of the finger 
movement, and I don’t think there’s any existing API that will give this to 
you. You would have to track the touches as reported to you over time, using 
the positional differences to estimate a velocity, and using velocity 
differences to estimate an acceleration, and then apply a heuristic to decide 
whether an acceleration exceeds a threshold for recognition as a “throw”.

However, given that your range of values is small (the table-view throwing has 
to deal with both short and long tables), you might be able to get away with a 
UIPanGestureRecognizer, if you aren’t going to require circular motion of the 
touches. It reports the velocity of the gesture, and you could try using a 
velocity threshold instead of an acceleration threshold — a fast movement 
throws to the extreme values, a slower movement tracks the finger — perhaps in 
conjunction with a minimum distance requirement.

Circular rubber banding is likely something you’re going to have to invent for 
yourself. You’re probably going to have to look up a formula for spring 
dampening to get it to look natural, and implement a custom animation timing 
curve.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to