Friday, May 1, 2009

iPhone: Touch, Drag, Hit!

Yesterday, Fredrik has asked me something like "Drag & Drop with Hit Test" on the iPhone. Here's a simple example.  There's a simple UIView class that handles the touch events and a protocol that says that if the "DragMe View" has hit or not the "HitMe View". Below you can see the result and the Source Code Link.

The source code is available here: Touch, Drag, Hit Source Code.


  1. Ah, er, um. This might interest you: -- BSD licensed. (And contributions/forks welcome.)

  2. If I wanted this to activate a button instead of a label , how would I do that?? Thanks any help is appreciated!!


  3. Hey how it the hitDelegate connected to the view? has it been connected using the interface builder. I tried implementing the protocol similar to your definition but I see no effect on my UI.

  4. The source code (link) is gone. Please publish (again). Your example is exacly what i'm looking for. thanks.