0

NSTableView をカスタマイズしようとしています。そのために、次のメソッドを実装しました。

-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{

    NSImageView *cellImage = [[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, 229, 51)];
    cellImage.image = [[NSImage alloc] initByReferencingFile:[[NSBundle mainBundle] pathForImageResource:@"list_cell_secetion_background.png"]];

    NSView *view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 229, 51)];

    NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(20, 10, 150, 30)];
    [textField setStringValue:[[_objects objectAtIndex:row] description]];
    [textField setBezeled:NO];
    [textField setDrawsBackground:NO];
    [textField setEditable:NO];
    [textField setSelectable:NO];

    if(row == selectedCell) [view addSubview:cellImage];

    [view addSubview:textField];

    return view;
}

したがって、ラベルの場所をクリックするまでは問題なく動作します。すると何も起こりません。セル内のどこでもクリックして、正しく選択したいと思います。

4

1 に答える 1