正确设置willSelectRowAtIndexPath和didSelectRowAtIndexPath以发送单元格选择

Gor*_*not 10 iphone uitableview didselectrowatindexpath

觉得我在这里有点疯狂.我有几个独立的详图UITextFieldS,一些UITextFieldsUITAbleViewCellS和一个单一的UITableViewCell,将被用来保存笔记,如果有任何.我只想在编辑模式下选择此单元格.当我不处于编辑模式时,我不希望能够选择它.选择单元格(在编辑模式下)将触发一个初始化视图的方法.我知道这很容易,但我在某处遗漏了一些东西.

以下是我正在使用的当前选择方法:

-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (!self.editing) {
        NSLog(@"Returning nil, not in edit mode");
        return nil;
    }
    NSLog(@"Cell will be selected, not in edit mode");
    if (indexPath.section == 0) {
        NSLog(@"Comments cell will be selected");
        return indexPath;
    }
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (!self.editing) {
        NSLog(@"Not in edit mode. Should not have made it this far.");
        return;
    }

    if (indexPath.section == 0)
        [self pushCommentsView];
    else
        return;
}
Run Code Online (Sandbox Code Playgroud)

我的问题真的是2倍;

1)即使我不是在编辑模式下,我知道我回来nil(由于NSLog消息),我仍然可以选择该行(它闪烁蓝色).根据我对该willSelectRowAtIndexPath方法的理解,这不应该发生.也许我对此错了?

2)当我进入编辑模式时,我根本无法选择任何内容.该willSelectRowAtIndexPath方法永远不会触发,而且也没有了didSelectRowAtIndexPath.我在该setEditing方法中唯一要做的就是在编辑时隐藏后退按钮,并指定firstResponder到顶部textField以弹出键盘.我想也许第一个响应者正在阻碍点击(这将是愚蠢的),但即使有注释,我也无法在编辑过程中执行单元格选择.

Gor*_*not 16

好主我是个白痴.我从来没有添加这些行:

self.tableView.allowsSelection = NO; // Keeps cells from being selectable while not editing. No more blue flash.
self.tableView.allowsSelectionDuringEditing = YES; // Allows cells to be selectable during edit mode.
Run Code Online (Sandbox Code Playgroud)

对不起垃圾问题.