UIGestureRecognizer
UIGestureRecognizer 是手势识别器基类,常见子类包括 tap/pan/pinch/longPress/rotation/swipe 等。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”| 属性 | 类型 | 说明 |
|---|---|---|
state | number | 手势状态。 |
enabled | boolean | 是否启用。 |
view | UIView | 附加的视图。 |
delegate | any | 委托。 |
cancelsTouchesInView | boolean | 是否取消视图中的触摸。 |
delaysTouchesBegan | boolean | 是否延迟 touchesBegan。 |
delaysTouchesEnded | boolean | 是否延迟 touchesEnded。 |
initWithTargetAction
Section titled “initWithTargetAction”用 target 与 action 初始化。
initWithTargetAction(target: any, action: string): voidParameters:
| Name | Type | Description |
|---|---|---|
target | any | 目标对象。 |
action | string | 方法名。 |
Return Value:
- 无。
addTargetAction
Section titled “addTargetAction”添加 target-action。
addTargetAction(target: any, action: string): voidParameters:
| Name | Type | Description |
|---|---|---|
target | any | 目标对象。 |
action | string | 方法名。 |
Return Value:
- 无。
removeTargetAction
Section titled “removeTargetAction”移除 target-action。
removeTargetAction(target: any, action: string): voidParameters:
| Name | Type | Description |
|---|---|---|
target | any | 目标对象。 |
action | string | 方法名。 |
Return Value:
- 无。
requireGestureRecognizerToFail
Section titled “requireGestureRecognizerToFail”要求另一手势失败后才识别。
requireGestureRecognizerToFail(otherGestureRecognizer: UIGestureRecognizer): voidParameters:
| Name | Type | Description |
|---|---|---|
otherGestureRecognizer | UIGestureRecognizer | 另一手势识别器。 |
Return Value:
- 无。
locationInView
Section titled “locationInView”手势在视图中的位置。
locationInView(view: UIView): anyParameters:
| Name | Type | Description |
|---|---|---|
view | UIView | 参考视图。 |
Return Value:
any: 点(如 { x, y })。
numberOfTouches
Section titled “numberOfTouches”当前触摸点数。
numberOfTouches(): numberReturn Value:
number: 触摸点数。
locationOfTouchInView
Section titled “locationOfTouchInView”指定触摸在视图中的位置。
locationOfTouchInView(touchIndex: number, view: UIView): anyParameters:
| Name | Type | Description |
|---|---|---|
touchIndex | number | 触摸索引。 |
view | UIView | 参考视图。 |
Return Value:
any: 点(如 { x, y })。
类成员 (Class members)
Section titled “类成员 (Class members)”当前运行时未额外暴露 UIGestureRecognizer 的类成员。
UITapGestureRecognizer、UIPanGestureRecognizer、UIPinchGestureRecognizer、UILongPressGestureRecognizer、UIRotationGestureRecognizer、UISwipeGestureRecognizer