【问题标题】:How to pause/disable UILongPressGestureRecognizer on a UITableViewCell while in editmode如何在编辑模式下暂停/禁用 UITableViewCell 上的 UILongPressGestureRecognizer
【发布时间】:2012-04-06 19:07:53
【问题描述】:

在表格视图中,我在每个单元格上都有一个 UILongPressGestureRecognizer,我添加如下:

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
                                          initWithTarget:self 
                                          action:@selector(TableCellLongPressed:)];
longPress.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:longPress];
[longPress release];

现在我确实遇到了以下问题,我希望用户能够重新排列 tableview 中的单元格,所以我有一个按钮可以将 tableView 设置为 EditMode,如下所示:

[self.myTableView setEditing:!self.myTableView.editing animated:YES];

现在,当用户尝试拖动一个单元格但没有将其拖得足够远时,longPress 会触发他的操作,这对用户来说非常烦人,因为会推送另一个视图。 tableView处于EditMode时如何暂停或禁用UILongPressGestureRecognizer

【问题讨论】:

    标签: iphone uitableview uigesturerecognizer long-press


    【解决方案1】:

    您应该为此方法实现 UIGestureRecognizerDelegate 委托:

    gestureRecognizer:shouldReceiveTouch:

    在方法中,检查你是否正在编辑表格,如果是则返回 NO。

    提姆

    【讨论】:

    • 不知道我怎么会忽略这种方法。谢谢,效果很好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多