문제

다음은 대리인의 VIEWFORTBRECOLUMN 메소드 안에 있습니다.목록보기에서 선택 항목을 기반으로 DataSource에 테이블 열을 동적으로 작성합니다.

    NSDictionary* rowData = [[self tableData] objectAtIndex:row];
    NSString* identifier = [tableColumn identifier];

    NSTableCellView* result = [tableView makeViewWithIdentifier:@"myCellView" owner:self];
    if (result == nil) {
        result = [[NSTableCellView alloc] initWithFrame:NSMakeRect(0, 0, 90.0, 10.0)];
        _textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 90.0, 10.0)];
        [result setTextField:_textField];
        [[result textField] setStringValue:[rowData objectForKey:identifier]];
    }
    else {
        [[result textField] setStringValue:[rowData objectForKey:identifier]];
    }
    NSLog(@"result text field: %@", [[result textField] stringValue]);

    return result;
.

이제

에서
-(void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView             forRow:(NSInteger)row {
NSLog(@"did add: %ld", row);
NSTableCellView* aView = [rowView viewAtColumn:0];
NSLog(@"%@", [[aView textField]stringValue]);
NSLog(@"%@",[[[rowView viewAtColumn:0 ] textField] stringValue]);
}
.

텍스트 필드는 좀비입니다.무엇을 주는가?당신의 도움을 주셔서 감사합니다.

도움이 되었습니까?

해결책

는 창 컨트롤러의 nstableCellView에 대한 참조 (iBoutlet)를 가져와야했습니다.그게 그것에 대해, 그 밖의 것은 없습니다.이제 NstableView 대리인의 식별자를 통해 해당 식별자에 액세스 할 수 있습니다.모든 열을 제거하고 테이블보기에 새 열을 추가 한 후에도 참조가 유지됩니다.

이제는 300-3000 행 범위의 테이블에서 매우 심각한 테이블 뷰 성능을 다루고 있습니다!그것은 또 다른 날입니다.

다른 팁

내가 생각할 수있는 유일한 것은 당신이 할 때 :

_textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 90.0, 10.0)];
.

이전에 _textField에서 릴리스 된 것은 무엇이든간에

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top