Iphone 编辑时uitableview单元格上的长按问题
请看下面我的代码。当我进入编辑模式时,由于长按识别器,我无法上下拖动单元格。如果我移除长按识别器,一切都会正常工作 感谢您的帮助Iphone 编辑时uitableview单元格上的长按问题,iphone,objective-c,ios,ios4,Iphone,Objective C,Ios,Ios4,请看下面我的代码。当我进入编辑模式时,由于长按识别器,我无法上下拖动单元格。如果我移除长按识别器,一切都会正常工作 感谢您的帮助 - (void)startEditingIndex { [self.navigationController setToolbarHidden:NO animated:YES]; [self.tableView setEditing:YES animated:YES]; } // Customize
- (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;
}
将您的类设置为
longPress
的委托,并实现以下委托方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return ![self.tableView isEditing];
}
将您的类设置为
longPress
的委托,并实现以下委托方法:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return ![self.tableView isEditing];
}
谢谢它看起来像@interface RootViewController:UITableViewController{我添加了你的代码,它没有任何不同。你需要
longPress.delegate=self;
。谢谢。它看起来像@interface RootViewController:UITableViewController{我添加了您的代码,它不会有任何不同。您需要longPress.delegate=self;
。