iPhone: detect "touch-and-drag" gesture from UIBarButtonItem?

Posted by Greg Maletic on Stack Overflow See other posts from Stack Overflow or by Greg Maletic
Published on 2010-04-11T18:40:49Z Indexed on 2010/04/11 18:43 UTC
Read the original article Hit count: 248

Filed under:
|
|

I have an "add" button that's represented by a UIBarButtonItem. Hitting the "add" button adds an object into a list that represents a moment in time. By default, that time is "now"...but I'd like to be able to use dragging behavior to let the user specify earlier times for the object. Here's the behavior I want to implement:

  • If the user touches on the UIBarButtonItem and lets go quickly, an object is added to the list that represents "now."

  • If the user touches on the UIBarButtonItem and drags, a little UI pops up that shows the time that the distance of their drag represents. The further they drag, the further back in time their touch will represent. When they let go, the object representing an earlier time will get added to the list.

(Though the description of the behavior is complicated, I'm convinced this will be pretty intuitive for users of the app.)

I haven't implemented code for anything but the most simple touches in the past, and I'm at a loss as to the best way to try this. Does anyone have any suggestions, or could point me towards some sample code that implements something like this?

Thanks very much.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about touch