【问题标题】:How to set time for touch the cell in a tableview?如何在表格视图中设置触摸单元格的时间?
【发布时间】:2012-01-10 09:12:14
【问题描述】:

大家好,我有一个表格视图,当我单击单元格时它会弹出一个视图,它对我来说工作正常,但我的问题是,我想点击 2 秒钟以弹出窗口。也就是说,如果我点击单元格 2 秒然后只有弹出应用程序。这可能吗?我该怎么做?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.view addSubview:MainPopupView];
//MainPopView is the popup that i want to display after2 minit
}

提前致谢。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    试试UILongPressGestureRecognizer。您可以设置minimumPressDuration来设置手势被识别的时间。

    您可以将UILongPressGestureRecognizer 添加到您的表格视图单元格并获得所需的操作。

    更新 请看一下这个之前的 SO 问题How can I determine if a user has pressed on a UITableViewCell for 2 seconds?

    【讨论】:

    • 我知道 longtapgesture 的类引用,但是如何在 didselectrowatindexpath 中实现?thnks。
    • 查看以前的 SO 问题 stackoverflow.com/questions/3924446/long-press-on-uitableview/… 为您提供了一个起点
    • 我有这个代码,我的弹出显示代码放在哪里?-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { CGPoint p = [gestureRecognizer locationInView:table]; NSIndexPath *indexPath = [表 indexPathForRowAtPoint:p]; if (indexPath == nil) NSLog(@"长按表格视图而不是一行"); else NSLog(@"长按第 %d 行的表格视图", indexPath.row); }
    猜你喜欢
    • 2012-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 2019-05-22
    相关资源
    最近更新 更多