Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 背景色不';无法在NSTableCellView中工作_Xcode_Cocoa_Background_Nstableview_Nstablecellview - Fatal编程技术网

Xcode 背景色不';无法在NSTableCellView中工作

Xcode 背景色不';无法在NSTableCellView中工作,xcode,cocoa,background,nstableview,nstablecellview,Xcode,Cocoa,Background,Nstableview,Nstablecellview,为什么背景色不能与owner:self.table一起使用?它只适用于owner:self,但是,第二个选项——awakeFromNib被多次调用 setStringValue可用于这两个选项 - (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSTableCellView *cell = [tableView make

为什么背景色不能与owner:self.table一起使用?它只适用于owner:self,但是,第二个选项——awakeFromNib被多次调用

setStringValue可用于这两个选项

- (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    NSTableCellView *cell = [tableView makeViewWithIdentifier:@"MainCell" owner:self.table];
    [cell.textField setStringValue:@"FunWithFlags"]
    cell.layer.backgroundColor = [[NSColor greenColor] CGColor];
    return cell;
}

owner参数需要NIB的owner对象,应该加载并实例化该对象,以使用提供的标识符创建新视图。 table对象self.table不是任何nib的所有者,因此它不返回任何视图