Iphone 如何在编辑模式下暂停/禁用UITableViewCell上的UILongPressGestureRecognitor
在表格视图中,我在每个单元格上都有一个Iphone 如何在编辑模式下暂停/禁用UITableViewCell上的UILongPressGestureRecognitor,iphone,uitableview,uigesturerecognizer,long-press,Iphone,Uitableview,Uigesturerecognizer,Long Press,在表格视图中,我在每个单元格上都有一个ui长按GestureRecognitor,我这样添加: UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector
ui长按GestureRecognitor
,我这样添加:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(TableCellLongPressed:)];
longPress.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:longPress];
[longPress release];
[self.myTableView setEditing:!self.myTableView.editing animated:YES];
现在我确实有以下问题,我希望用户能够在tableview中重新排列单元格,因此我有一个按钮,可以将tableview设置为编辑模式,如下所示:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(TableCellLongPressed:)];
longPress.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:longPress];
[longPress release];
[self.myTableView setEditing:!self.myTableView.editing animated:YES];
现在,当用户尝试拖动单元格时,如果拖得不够远,longPress会启动他的操作,这对用户来说非常烦人,因为会推送另一个视图。
当tableView处于编辑模式时,如何暂停或禁用UILongPressGestureRecognitizer。您应该为此方法实现UIGestureRecognitizer委托: 手势识别器:应接收触摸: 在方法中,检查是否正在编辑该表,如果正在编辑,则返回NO
蒂姆不知道我怎么会忽视这种方法。谢谢,很好用。