IOS中的手势详解
1、点击 UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click)]; //设置当前需要点击的次数 [tap setNumberOfTapsRequired:1]; //设置当前需要触发事件的手指数量 [tap setNumberOfTouchesRequired:2]; //设置当前代理 tap.delegate=self; [_view addGestureRecognizer:tap]; //触发方法 - (void) click{ NSLog(@"当前视图被点击了! "); } 2、长按 UILongPressGestureRecognizer * longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)]; //设置当前长按最小的时长 longPress.minimumPressDuration=2; //设置允许的移动范围 [longPress setAllowableMovement:2]; [_view addGestureRecognizer:longPress]; //触发方法 -