侧边栏壁纸
博主头像
最闪啊姚凌武!博主等级

天下武功,唯快不破

  • 累计撰写 293 篇文章
  • 累计创建 34 个标签
  • 累计收到 10 条评论

目 录CONTENT

文章目录

IOS长按事件的方法

姚凌武
2014-09-22 / 0 评论 / 0 点赞 / 11 阅读 / 2031 字
- (id)initWithFrame:(CGRect)frame {

UITableView *tmpTblView = [[UITableView alloc] initWithFrame:self.frame];

.......

//实例化长按手势监听

UILongPressGestureRecognizer *longPress =

[[UILongPressGestureRecognizer alloc] initWithTarget:self

action:@selector(handleTableviewCellLongPressed:)];

        //代理

longPress.delegate = self;

        longPress.minimumPressDuration = 1.0;

//将长按手势添加到需要实现长按操作的视图里

        [tmpTblView addGestureRecognizer:longPress];

        [longPress release];

[tmpTblView release];

}

//长按事件的实现方法

- (void) handleTableviewCellLongPressed:(UILongPressGestureRecognizer *)gestureRecognizer {

    if (gestureRecognizer.state ==  UIGestureRecognizerStateBegan) {

        NSLog(@"UIGestureRecognizerStateBegan");

    }

if (gestureRecognizer.state ==  UIGestureRecognizerStateChanged) {

        NSLog(@"UIGestureRecognizerStateChanged");

    }

 

if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {

        NSLog(@"UIGestureRecognizerStateEnded");

    }

 

}

]]>
0
iOS

评论区