简体   繁体   中英

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!

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.

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 (eg draw the touch points on the screen), and also let the views handle the touches as before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM