NSTableView добавить кнопку или любой другой пользовательский объект - PullRequest
0 голосов
/ 02 мая 2018

Я пытаюсь добавить кнопку программно в NSTableView, который также определен программно, но пока не повезло. Мой последний код:

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
        auto dataRow = _tasks[row];
    if([tableColumn.identifier isEqualToString:@"Id"]) {
        NSTextField* text = [[NSTextField alloc] init];
        text.stringValue = [NSString stringWithUTF8String:dataRow[0].c_str()];
        return text;

    } else if([tableColumn.identifier isEqualToString:@"Name"]) {
        NSTextField* text = [[NSTextField alloc] init];
        text.stringValue = [NSString stringWithUTF8String:dataRow[1].c_str()];
        return text;

    } else if([tableColumn.identifier isEqualToString:@"Check"]) {
        NSTableCellView* cellView = [[NSTableCellView alloc] initWithFrame:NSMakeRect(0, 0, 200, 100)];



        NSPopUpButtonCell* popupButtonCell = [[NSPopUpButtonCell alloc] init];
        [popupButtonCell setPullsDown:YES];
        [popupButtonCell insertItemWithTitle:@"dsadsa1" atIndex:0];
        [popupButtonCell insertItemWithTitle:@"dsadsa2" atIndex:1];

        NSPopUpButton* popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 100) pullsDown:YES];

        popupButton.cell = popupButtonCell;

        [popupButton insertItemWithTitle:@"dsadsa" atIndex:0];
        [popupButton insertItemWithTitle:@"dsadsa" atIndex:1];

        NSTextField* text = [[NSTextField alloc] init];
        NSTextFieldCell* textCell = [[NSTextFieldCell alloc] initTextCell:@"dsadsad"];
        text.stringValue = [NSString stringWithUTF8String:"titleee"];
        text.cell = textCell;

        [cellView addSubview:text];
        [cellView addSubview:popupButton];

        return cellView;

    }

последний столбец по какой-то причине отображается пустым

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...