一:手势事件类型
1.父类
UIGestureRecognizer 是一个抽象类,是所有手势事件的父类。
The concrete subclasses of UIGestureRecognizer are the following:
UITapGestureRecognizer //轻拍
UIPinchGestureRecognizer //捏合
UIRotationGestureRecognizer //旋转
UISwipeGestureRecognizer //扫
UIPanGestureRecognizer//拖拽
UILongPressGestureRecognizer //长按
2,如何添加手势事件及响应
(1)添加:调用 UIVIEW及其子类的 addGestureRecognizer:
(2)响应函数样式比如是下面两种的一种形式
- (void)handleGesture;
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer;
- (void)viewDidLoad {
//---tap gesture---
UITapGestureRecognizer *tapGesture =[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleTapGesture:)];
tapGesture.numberOfTapsRequired = 2;
[imageView addGestureRecognizer:tapGesture];
[tapGesture release];
[super viewDidLoad];
}
//---handle tap gesture---
-(IBAction) handleTapGesture:(UIGestureRecognizer *) sender {
if (sender.view.contentMode == UIViewContentModeScaleAspectFit)
sender.view.contentMode = UIViewContentModeCenter;
else
sender.view.contentMode = UIViewContentModeScaleAspectFit;
}
3。
UITapGestureRecognizer
numberOfTapsRequired :设置轻击的次数,默认值为1
numberOfTouchesRequired :触点的数量,默认值为1,即手指数
UIPinchGestureRecognizer
当两个手指靠近表示zoom-in,当两个手指分离表示zoom-out。
scale
@property(nonatomic) CGFloat scale,放大缩小因子
velocity
@property(nonatomic, readonly) CGFloat velocity ,只读属性 ,表示移动速度
UIRotationGestureRecognizer
rotation :旋转角度
velocity :速度
UISwipeGestureRecognizer
direction :扫动方向,默认值UISwipeGestureRecognizerDirectionRight
typedef enum {
UISwipeGestureRecognizerDirectionRight = 1 << 0,
UISwipeGestureRecognizerDirectionLeft = 1 << 1,
UISwipeGestureRecognizerDirectionUp = 1 << 2,
UISwipeGestureRecognizerDirectionDown = 1 << 3
} UISwipeGestureRecognizerDirection;
numberOfTouchesRequired : 触点的数量,默认值为1,即手指数
UIPanGestureRecognizer
maximumNumberOfTouches :最大触摸的数量
minimumNumberOfTouches :最少触摸的数量
– translationInView:
A point identifying the new location of a view in the coordinate system of its designated superview.
(一个点确定一个新的位置在其指定的父视图的坐标系统)
– setTranslation:inView:
The velocity of the pan gesture, which is expressed in points per second. The velocity is broken into horizontal and vertical components.
(手势的速度,这是表示在每分每秒。速度分解为水平和垂直分量。)
– velocityInView:
- (CGPoint)velocityInView:(UIView *)view
UILongPressGestureRecognizer
minimumPressDuration :长按最短的时间
numberOfTouchesRequired :
numberOfTapsRequired :
allowableMovement :长按时运行移动的最大距离,默认值为10个像素
手指事件生命周期(状态)
取得当前手势状态
@property(nonatomic,readwrite) UIGestureRecognizerState state;
Possible ----> Began ----> [Changed] ----> Cancelled
Possible ----> Began ----> [Changed] ----> Ended
typedef enum {
UIGestureRecognizerStatePossible,
UIGestureRecognizerStateBegan,
UIGestureRecognizerStateChanged,
UIGestureRecognizerStateEnded,
UIGestureRecognizerStateCancelled,
UIGestureRecognizerStateFailed,
UIGestureRecognizerStateRecognized = UIGestureRecognizerStateEnded } UIGestureRecognizerState;
分享到:
相关推荐
来源于 Nokia 官方网网站 Nokia PC Connectivity SDK 3.0
arcgis js sdk 3.0目前最新版本,与online版本一致,配合arcgis js api 3.0一起下载使用
其实这几个bug在安装SDK3.0后的Micro Framework SDK Release Notes.txt中已经有了说明。 主要有如下两个问题: (1) 非英文版VS2008安装SDK3.0后,在新建项目中无micro Framework选项 解决办法: If you are ...
brew sdk 3.0.1.12.rar
esp8266 nonos sdk 3.0
ESP8266_NONOS_SDK-3.0.zip官方的包没做任何的修改,防止官网下载缓慢。
dotnet core 3.0 的 sdk 支持编译 需要说明的一点的是,DotNetCore 3.0 虽然跨平台,但是基于此的 WPF 却是针对 Windows 特定平台的实现,并不能跨 Linux 和 MacOS
海康 Web SDK 3.0 1.0.9 版 OCX 和 NPAPI 支持 IE Firefox Chrome
Flex Sdk 3.0
ESP8266_RTOS_SDK-3.0官方包,留作下载用以备需要。。
java+flex进销存系统sdk3.0,网上收集到的
针对linux操作系统的 android sdk tool 只是个tool,sdk还要自己下载 手机开发平台 Google Android SDK 3.0 R9 Android eclipse插件安装: https://dl-ssl.google.com/Android/eclipse/ Android netBean插件安装: ...
MSXML sdk 3.0、4.0、5.0、6.0
基于S32KDS平台SDK3.0编写的flexcan组件can fd测试例程
基于S32KDS平台SDK3.0编写的wdog组件例程
ESP8266_NONOS_SDK-3.0.zip,8266sdk文件
MRE SDK 3.0 沃勤斯凯MTK,用于开发MRE3.0平台软件游戏!
海康威视最新的WebSDK开发包,可直接在浏览器(IE,旧版本Chrome,火狐)播放海康摄像头视频,以及云台。包含PDF说明书和全部源代码,来自公司对接海康客服,共享给有需要的人!
flex_sdk_3.0.0.477A
基于S32KDS平台SDK3.0编写的lin组件测试例程,不使用LDF配置,手动配置lin