0

私はNSTableView動的に列を追加します。setDataCellセルをカスタマイズするための呼び出しを追加しました。コードは次のようになります。

for(NSUInteger columnIndex = 0; columnIndex < resultSet.columNames.count; ++columnIndex)
{
    NSTableColumn * newColumn = [[NSTableColumn alloc] initWithIdentifier: [NSString stringWithFormat: @"%ld", columnIndex]];

    [newColumn.headerCell setAlignment: NSCenterTextAlignment];
    [newColumn.headerCell setStringValue: resultSet.columNames[columnIndex]];
    [newColumn setDataCell: [[HSDisclosureTextFieldCell alloc] init]];
    [newColumn setEditable: YES];

    [resultsTableView addTableColumn: newColumn];
    if(newColumn.width < 60) [newColumn sizeToFit];
} // End of column loop

への呼び出しを削除してsetDataCellも、エントリをダブルクリックして編集できます。

次の内容を最小化しましたHSDisclosureTextFieldCell(オーバーライドなし):

@interface HSDisclosureTextFieldCell : NSTextFieldCell
{
}

しかし、ダブルクリックしてフィールドを編集することはできません。

私が間違っているアイデアはありますか?

4

1 に答える 1

0

私がやっているにもかかわらず、判明:

[newColumn setEditable: YES];

そして持っています:

- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row

実装されたので、次のように切り替える必要がありましたsetDataCell

HSDisclosureTextFieldCell * cell = [[HSDisclosureTextFieldCell alloc] init];
[cell setEditable: YES];
[newColumn setDataCell: cell];

私がそれをしたので、すべてが適切に機能しているようです。

于 2014-08-06T11:13:13.120 に答える