Taylor
Taylor

Reputation: 6440

showing touches on iOS device like in the simulator

For the purposes of making app demos and presentations, I would like to draw circles corresponding to touches, just like in the iOS simulator, but on the device itself.

Ideally, this would be orthogonal to other code. Perhaps a UIView which draws the circles and forwards the events, but event forwarding seems to require the other views be aware:

http://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html#//apple_ref/doc/uid/TP40009541-CH3-SW17

Is there a clean way of doing this?

(I can't use the simulator for demos because my app uses gestures, MIDI, and OpenGL)

thanks!

Upvotes: 1

Views: 534

Answers (2)

TotoroTotoro
TotoroTotoro

Reputation: 17622

I don't think there's a clean way of doing this. However, this is what I would try:

Use method swizzling to hook up to all your views by swizzling the methods

- touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:

for the UIView class. In addition, you may also need to swizzle some methods of UIGestureRecognizer subclasses, since they may prevent the methods listed above from being called. This way you can do your own thing (e.g. draw the touch points on the screen), and also let the views handle the touches as before.

Upvotes: 0

Fogmeister
Fogmeister

Reputation: 77661

There is a framework call fingertips which is available through cocoapods.

http://cocoapods.org/?q=on%3Aios%20fingertips

This will do what you are asking.

Upvotes: 4

Related Questions