0

テキストフィールドとボタンを備えた非常に単純な NSTableCellView を作成しようとしています。NSTableCellView をレイアウトする私のコードは以下のとおりです。テキストフィールドの幅を 100px にしたい。

- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {

    MyTableCellView *cellView = [outlineView makeViewWithIdentifier:@"MyTableCellView" owner:self];

     if (cellView == nil) {
         cellView = [[MyTableCellView alloc] initWithFrame:NSMakeRect(0, 0, NSWidth(outlineView.bounds), [outlineView rowHeight])];

         NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, [outlineView rowHeight])];
         [cellView addSubview:textField];
         cellView.textField = textField;

         NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(108, 0, 50, [outlineView rowHeight])];
         [cellView addSubview:button];
         cellView.button = button;

         cellView.identifier = @"MyTableCellView";
     }

     cellView.textField.stringValue = item.stringValue;

     return cellView;
}

ただし、これを行うと、NSTextField が行全体を占有します。

私は何を間違っていますか?

4

1 に答える 1