0
请参阅下面的代码。当我进入编辑模式时,由于长按识别器,我无法上下拖动单元格。如果我删除了长按识别器,则所有内容都可以正常工作。编辑时对uitableview单元格的长按问题
任何帮助表示赞赏。
- (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;
}
谢谢。它看起来像@interface RootViewController:UITableViewController { 我添加了你的代码,它没有做任何不同的事情。 –
Alienz
你需要'longPress.delegate = self;'。 – titaniumdecoy