UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(lpGR:)];
//设定最小的长按时间 按不够这个时间不响应手势
longPressGR.minimumPressDuration=0.7;
[celladdGestureRecognizer:longPressGR];
#pragma mark -实现手势对应的功能
-(void)lpGR:(UILongPressGestureRecognizer *)lpGR
{
if (lpGR.state == UIGestureRecognizerStateBegan) {//手势开始
CGPointpoint = [lpGRlocationInView:self.tableViewNoticeDetails];
NSIndexPath*indexPath = [self.tableViewNoticeDetailsindexPathForRowAtPoint:point];
if(indexPath !=nil){
NSIntegerindexNum = indexPath.row;
NSLog(@"点击的是第%ld行",(long)indexNum);
}
}
if (lpGR.state == UIGestureRecognizerStateEnded){
//手势结束
[self longPressDelete];//添加弹窗
}
}
-(void)longPressDelete
{
ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@[@"删除"] actionSheetBlock:^(NSInteger buttonIndex) {
if(buttonIndex ==0) {
}
}];
[actionSheetshow];
}
网友评论