Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 编辑时uitableview单元格上的长按问题_Iphone_Objective C_Ios_Ios4 - Fatal编程技术网

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;