3

NSBrowser ビューを使用して、ファインダー タイプのアプリでファイルとフォルダーのリストを表示しています。NSBrowser 用の新しい Item Base Api を使用しています。

willDisplayCell問題は、メソッドでイメージを設定しようとしたときです。ビューには何も表示されません。

コード:

// This is a utility method to find the parent item for a given column. The item based API eliminates the need for this method.
- (FileSystemNode *)parentNodeForColumn:(NSInteger)column {
    if (_rootNode == nil) {
        _rootNode = [[FileSystemNode alloc] initWithURL:[NSURL fileURLWithPath:@"/Users/kiritvaghela"]];
    }

    FileSystemNode *result = _rootNode;
    // Walk up to this column, finding the selected row in the column before it and using that in the children array
    for (NSInteger i = 0; i < column; i++) {
        NSInteger selectedRowInColumn = [_browser selectedRowInColumn:i];
        FileSystemNode *selectedChildNode = [result.children objectAtIndex:selectedRowInColumn];
        result = selectedChildNode;
    }

    return result;
}

- (void)browser:(NSBrowser *)browser willDisplayCell:(NSBrowserCell *)cell atRow:(NSInteger)row column:(NSInteger)column {
    FileSystemNode *parentNode = [self parentNodeForColumn:column];
    FileSystemNode *childNode = [parentNode.children objectAtIndex:row];

    [cell setTitle:childNode.displayName];

    cell.image = node.icon;

}

Apple SimpleCocoaBrowser の例

4

2 に答える 2