[IOS]UILongPressGestureRecognizer 执行两次的问题
2014-05-22 09:22
495 查看
[align=center]UILongPressGestureRecognizer 执行两次的问题
[/align]
IOS长按手势,默认长按后会两次进入所关联的方法,若只需要改变一次状态就需要用代码将两次方法响应分隔开...
长按Button右上弹出一个小叉,再次长按Button右上小叉消失
[/align]
IOS长按手势,默认长按后会两次进入所关联的方法,若只需要改变一次状态就需要用代码将两次方法响应分隔开...
长按Button右上弹出一个小叉,再次长按Button右上小叉消失
//每个UICollectionView展示的内容 -(BJNewsShelfCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { BJNewsShelfCell *cell = (BJNewsShelfCell *)[collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; //添加长按手势 UILongPressGestureRecognizer *pressGes = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellLongPressAction:)]; [cell addGestureRecognizer:pressGes]; pressGes.minimumPressDuration = 1.0;//触发长按事件的时间是1秒 pressGes.view.tag = theRow; return cell; } //添加长按手势 -(void)cellLongPressAction:(UILongPressGestureRecognizer *)sender{ //这里长按一次会进入两次 if (sender.state == UIGestureRecognizerStateEnded || sender.state ==UIGestureRecognizerStateChanged) { //sender.state ==UIGestureRecognizerStateChanged这个限制不添加也不影响执行一次的功能,只是若长按住View不放手,一直在上面拖动的话,会一直响应下面else }else { //这里长按一次只会进入一次 if(_isLongPress == 1){ _isLongPress = 0; }else{ _isLongPress = 1; } NSLog(@"cellLongPressAction"); [_collectionView reloadData]; } }
相关文章推荐
- UILongPressGestureRecognizer 执行两次的问题
- IOS给tableview的cell添加长按手势执行两次(UILongPressGestureRecognizer)
- UILongPressGestureRecognizer 执行两次的解决办法
- ios 长按事件 ( UILongPressGestureRecognizer长按事件 (2013-02-21 16:10:41)转载▼
- ios手势之UILongPressGestureRecognizer
- 关于UILongPressGestureRecognizer调用多次的问题
- 关于UILongPressGestureRecognizer调用多次的问题
- UILongPressGestureRecognizer的两次触发
- UILongPressGestureRecognizer 触发两次解决
- ios 长按手势UILongPressGestureRecognizer 开始/结束(按下/抬起)
- uilongPressGestureRecognizer 的两次(多次)触发
- UILongPressGestureRecognizer 的两次触发
- iOS长按手势UILongPressGestureRecognizer
- UILongPressGestureRecognizer的介绍
- UITableView长按手势UILongPressGestureRecognizer
- UILongPressGestureRecognizer
- UILongPressGestureRecognizer的selector多次调用解决方法
- ios中interactivePopGestureRecognizer的问题解决方法
- IOS长按事件--UILongPressGestureRecognizer
- UITableView 添加长按手势UILongPressGestureRecognizer