长按手势获取UITableView的indexPath值,删除某行
来源:互联网 发布:西安科技大学考研 知乎 编辑:程序博客网 时间:2024/05/18 01:25
- (void)viewDidLoad
{
//给cell加长按手势
UILongPressGestureRecognizer *gestureLongPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(gestureLongPress:)];
gestureLongPress.minimumPressDuration =1;
[self.tableV0addGestureRecognizer:gestureLongPress];
[gestureLongPressrelease];
}
#pragma mark - 长按手势
- (void)gestureLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{
CGPoint tmpPointTouch = [gestureRecognizer locationInView:self.tableV0];
if (gestureRecognizer.state ==UIGestureRecognizerStateBegan) {
NSIndexPath *indexPath = [self.tableV0indexPathForRowAtPoint:tmpPointTouch];
if (indexPath == nil) {
NSLog(@"not tableView");
}else{
focusSection = [indexPath section];
focusRow = [indexPath row];
NSLog(@"%d",focusSection);
NSLog(@"%d",focusRow);
deletebtn.hidden =NO;
}
}
}
//删除
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:focusRow inSection:focusSection];
[self.tableV0 deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
之前见过见过这样的函数:CGRectContainsPoint() // 用来判断一个点 是否在矩形区域内
具体点:
//隐藏
-(void)dismiss:(UITapGestureRecognizer *)tap{
if(CGRectContainsPoint(self.frame, [taplocationInView:_buttomView])) { // 注意tap获取点的View一定要大于你要判断的矩形区域,否则有bug;
NSLog(@"tap"); /// 参数: 区域范围(CGrect),判别的区域(CGpoint) 如果点到了判别区域slog,否则使消失
} else{
[selfdismissBlock:^(BOOL complete) {
}];
}
}
//删除
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:focusRow inSection:focusSection];
[self.tableV0 deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- 长按手势获取UITableView的indexPath值,删除某行
- 长按手势获取UITableView的indexPath值,删除某行
- UITableView获取cell的indexPath
- UITableView获取cell的indexPath
- UITableView获取cell的indexPath.row值(多种方式)
- 通过cell中的元素获取cell的indexPath以及长按tableview获取选中cell的indexPath
- UITableView长按手势UILongPressGestureRecognizer
- UITableView长按手势UILongPressGestureRecognizer
- 长按手势删除tableView选中的行
- UITableView 添加长按手势UILongPressGestureRecognizer
- 获取长按手势所点击的cell的行号
- UITableView,根据indexPath设置cell的编辑样式,删除cell ,增加cell &搜索条
- 根据indexPath拿到UITableView的cell
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- tableView的indexPath值错误导致删除崩溃
- UITableView 的长按事件
- NOIP 2011 Day1 T2 选择客栈
- 谈C#中的Delegate
- Golang开发新手常犯的50个错误
- 传统制造如何走向“智能制造”
- webstorm快捷键
- 长按手势获取UITableView的indexPath值,删除某行
- Two Sum--leetcode
- Win7 64位环境下,vs2013和Opencv2.4.13的配置
- 实习过程中常用到的 技巧(1)
- leetCode_Permutation Sequence
- NOIP 2012 Day1 T3 开车旅行
- [AIR]批量修改目录中图片的操作方式
- LED发光管实验报告
- AOE网关键路径的算法,最最最最直接的算法,一学就会