// 手势识别是具有互斥的原则的,比如单击和双击,如果它识别出一种手势,其后的手势将不被识别
// 添加单击的手势
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizeralloc] init];
tapGestureRecognizer.numberOfTapsRequired = 1; // 设置单击几次才触发方法
[tapGestureRecognizer addTarget:self action:@selector(tapGestureAction:)]; //添加点击手势的方法
[self.view addGestureRecognizer:tapGestureRecognizer]; // 添加到当前的View上
[tapGestureRecognizer release], tapGestureRecognizer = nil; // 释放内存
// 添加长按的手势 注意:会调用两次方法,开始长按调用一次 松开后再调用一次 当长按并且滑动的时候,会多次调用长按的方法
UILongPressGestureRecognizer *pressLongGestureRecognizer = [[UILongPressGestureRecognizer alloc] init];
[pressLongGestureRecognizer addTarget:selfaction:@selector(pressLongGestureAction:)]; // 给长按手势添加方法
[self.view addGestureRecognizer:pressLongGestureRecognizer]; // 添加到当前的View上
[pressLongGestureRecognizer release], pressLongGestureRecognizer = nil; // 释放内存