请参阅下面的代码。当我进入编辑模式时,由于长按识别器,我无法上下移动单元格。如果我删除长按识别器,一切都会正常工作。
感谢任何帮助。
- (void)startEditingIndex
{
[self.navigationController setToolbarHidden:NO animated:YES];
[self.tableView setEditing:YES animated:YES];
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
}
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startEditingIndex)];
[cell addGestureRecognizer:longPress];
[longPress release];
NSString *cellText = @"Text";
cell.textLabel.text = [[self.indexArry objectAtIndex:[[self.indexOrder objectAtIndex:indexPath.row] intValue]] objectForKey:cellText];
return cell;
}
答案 0 :(得分:3)
将您的类设置为longPress
的委托,并实现以下委托方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return ![self.tableView isEditing];
}