zoukankan      html  css  js  c++  java
  • UITableViewCell 的长按事件处理

    今天做任务的时候遇到了UITableViewCell的长按处理,比如按住一秒之后触发事件。刚开始本想自定义cell,然后在里面捕捉touch事件,touchbegin后开始计时,超过一秒触发事件,不过想想如此有点麻烦,然后查下了orgnizer,发现了

    UILongPressGestureRecognizer这个类,嘿嘿,确实是我需要的,然后查看文档,发现其可以支持多指长按,不过这里我需要单指就可以了。使用方法也比较方便,大家直接参考代码就可以了:

    UILongPressGestureRecognizer *longPressReger = [[UILongPressGestureRecognizer alloc]

    initWithTarget:self action:@selector(handleLongPress:)];

    longPressReger.minimumPressDuration = 1.0;

    [myTableView addGestureRecognizer:longPressReger];

    [longPressReger release];

     

    -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer

    {

    CGPoint point = [gestureRecognizer locationInView:myTableView];

     

    if(gestureRecognizer.state == UIGestureRecognizerStateBegan)

    {

    }

    else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)

    {

    }

    else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)

    {

    }

    NSIndexPath *indexPath = [myTableView indexPathForRowAtPoint:point];

    if (indexPath == nil)

    NSLog(@”not tableView”);

    else

    {

    focusRow = [indexPath row];

    focusView.hidden = NO;

    }

    }

  • 相关阅读:
    eventkeyboardmouse
    代理 IP
    网关 192.168.2.1 114.114.114.114 dns查询
    http ssl
    SSDP 抓包
    抓包登录信息提交
    危险的input 微博的过去
    firstChild.nodeValue
    浏览器控制台
    haproxy 中的http请求和https请求
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090546.html
Copyright © 2011-2022 走看看