简体   繁体   English

我可以为iPhone创建自定义触摸事件吗

[英]Can i create custom touch events for iPhone

Can i create custom touch events for iPhone?? 我可以为iPhone创建自定义触摸事件吗? will the device support for creating my own touch event handling ? 该设备是否支持创建我自己的触摸事件处理?

Take a look at the UIResponder class: http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html 看一下UIResponder类: http : //developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIResponder_Class/Reference/Reference.html

You will probably want to implement the touchesBegan:withEvent: , touchesEnded:withEvent: and touchesCancelled:withEvent: methods. 您可能需要实现touchesBegan:withEvent:touchesEnded:withEvent:touchesCancelled:withEvent:方法。 These will all be called with an NSSet of UITouches that you can do whatever you want with. 这些都将通过UITouches的NSSet来调用,您可以用它进行任何操作。

As of the 3.2 SDK there are UIGestureRecognizer classess. 从3.2 SDK开始,有UIGestureRecognizer类。 They do not play well with the older UIResponder calls, but if you can do 3.2 only they are easier to get going. 它们不能与较旧的UIResponder调用配合使用,但是,如果您只能执行3.2,则更容易进行。

There are a number of handy subclasses, such as UIRotationGestureRecognizer for handling rotation. 有许多方便的子类,例如用于处理旋转的UIRotationGestureRecognizer。

If you are extending Apple classes like UIScrollView you must use gesture recognizers with 3.2 and later because when a gesture recognizer cancels it will cancel your UIResponder call tracking as well. 如果要扩展Apple类(如UIScrollView),则必须在3.2和更高版本中使用手势识别器,因为取消手势识别器也会同时取消UIResponder调用跟踪。 If you are handling all the gesture tracking this is not an issue. 如果您正在处理所有手势跟踪,那么这不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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