iOS 长按手势

-(void)viewDidAppear:(BOOL)animated{
    _lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
    _lpgr.minimumPressDuration = 1.0; //seconds  设置响应时间
    _lpgr.delegate = self;
    [_myTableView addGestureRecognizer:_lpgr]; //启用长按事件
    NSLog(@"value1=%@",_value1);
}

-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer  //长按响应函数
{
    CGPoint p = [gestureRecognizer locationInView:_myTableView ];
    
    if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
    {
        NSIndexPath *indexPath = [_myTableView indexPathForRowAtPoint:p];//获取响应的长按的indexpath
        // 待支付
        _bepaidValue = [_requestData[indexPath.row] valueForKey:@"IsNoPayCount"];
        //待确认
        _beConfirmedValue = [_requestData[indexPath.row] valueForKey:@"UnPayCount"];
        
        NSString *str=[_requestData[indexPath.row] valueForKey:@"IsConfrimCount"];
        NSString *str2= [_requestData[indexPath.row] valueForKey:@"IsPayCount"];
        NSString *str3= [_requestData[indexPath.row] valueForKey:@"IsNoPayCount"];
        float fl = [str floatValue];
        float fl2 = [str2 floatValue];
        float fl3 = [str3 floatValue];
        float fl4 = fl-fl2-fl3;
        //待生成
        _beGenerated = [NSString stringWithFormat:@"%.0f",fl4];
        _aidstr = [[NSString alloc]init];
        _aidstr = [_requestData[indexPath.row] valueForKey:@"AID"];
        _atypeValue =[_requestData[indexPath.row] valueForKey:@"AType"];
        

        
        
        [self aleartViewShowtTittle:@"提示信息" message:nil];
//        [self aleartViewShowtTittle:@"修改信息" message:nil ok:@"编辑" other:@"删除" other2:@"添加" cancel:@"取消"];
        //    if (indexPath == nil)
        //        NSLog(@"long press on table view but not on a row");
        //
        //    else
        //        NSLog(@"long press on table view at row %ld",indexPath.row);
    NSLog(@"UIGestureRecognizerStateBegan");
    }
    //else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
    //{
    //NSLog(@"UIGestureRecognizerStateEnded");
    //}
    //else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
    //{
    //NSLog(@"UIGestureRecognizerStateChanged");
    //}
    //else if(gestureRecognizer.state == UIGestureRecognizerStateCancelled)
    //{
    //NSLog(@"UIGestureRecognizerStateCancelled");
    //}
    //else if(gestureRecognizer.state ==UIGestureRecognizerStateFailed )
    //{
    //NSLog(@"UIGestureRecognizerStateFailed");
    //}    
    
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值