你的位置:首页 > 软件开发 > 操作系统 > iOS Programming UIGestureRecognizer and UIMenuController

iOS Programming UIGestureRecognizer and UIMenuController

发布时间:2015-05-15 15:03:49
iOS  Programming  UIGestureRecognizer and UIMenuControllerA UIGestureRecognizer intercepts touches that are on their way to being ...

iOS  Programming  UIGestureRecognizer and UIMenuController

iOS  Programming  UIGestureRecognizer and UIMenuController

A UIGestureRecognizer intercepts touches that are on their way to being handled by a view.

一个UIGestureRecognizer拦截touches 在他们被一个view处理的路上。

When it recognizes a particular gesture, it sends a message to the object of your choice.

当它检测到一个特殊的手势时,它就会发送一个消息给你选中的特殊的对象。

There are several types of gesture recognizers built into the SDK.

在内部的SDK中,有一些特殊的手势类型。

1  UIGestureRecognizer Subclasses

You do not instantiate UIGestureRecognizer itself. Instead, there are a number of subclasses of UIGestureRecognizer, and each one is responsible for recognizing a particular gesture.

你并不会实例化UIGestureRecognizer自身,而是有一些UIGestureRecognizer的子类,这些子类负责鉴别一个特殊的手势。

To use an instance of a UIGestureRecognizer subclass, you give it a target-action pair and attach it to a view.

为了实例化UIGestureRecognizer子类,你给了它一个target-action pair 并把它与一个view 联系在一起。

Whenever the gesture recognizer recognizes its gesture on the view, it will send the action message to its target.

当一个gesture recognizer 识别出了在view 上的手势,它将会发送动作信息给它的target。

- (void)action:(UIGestureRecognizer *)gestureRecognizer;

When recognizing a gesture, the gesture recognizer intercepts the touches destined for the view

当鉴别出一个手势后,它的gesture recognizer 为指定的view解析这个touches。

Thus, a view with gesture recognizers may not receive the typical UIResponder messages like touchesBegian:withEvent:.

因此一个有gesture recognizers的view 可能不接受典型的UIResponder 消息,比如touchesBegian:withEventiOS  Programming  UIGestureRecognizer and UIMenuController

2 Detecting Taps with UITapGestureRecognizer

The first UIGestureRecognizer subclass you will use is UITapGestureRecognizer.

第一个你将会使用的UIGestureRecognizer子类是UITapGestureRecognizer。

When the user taps the screen twice, all of the lines on the screen will be cleared.

当用户点击屏幕两次的时候,所有的线就会被清除掉。

 

In BNRDrawView.m, instantiate a UITapGestureRecognizer that requires two taps to fire in initWithFrame:.

UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self

action:@selector(doubleTap:)]; doubleTapRecognizer.numberOfTapsRequired = 2;

[self addGestureRecognizer:doubleTapRecognizer];

 

- (void)doubleTap:(UIGestureRecognizer *)gr

{

原标题:iOS Programming UIGestureRecognizer and UIMenuController

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。