Macos 如何制作大纲视图:objectValueForTableColumn:。。接受attributedString
我试图使大纲单元格以粗体文本显示属性字符串。这是一个基于单元格的大纲 下面是创建AttributeString的方法:Macos 如何制作大纲视图:objectValueForTableColumn:。。接受attributedString,macos,nsattributedstring,nsoutlineview,nscell,Macos,Nsattributedstring,Nsoutlineview,Nscell,我试图使大纲单元格以粗体文本显示属性字符串。这是一个基于单元格的大纲 下面是创建AttributeString的方法: anObject.name =[[NSMutableAttributedString alloc]initWithString:@"Draft Chapters"] ; [anObject.name beginEditing]; [anObject.name applyFontTraits:NSBoldFontMask range:NSMakeRange(0, 14)]; [
anObject.name =[[NSMutableAttributedString alloc]initWithString:@"Draft Chapters"] ;
[anObject.name beginEditing];
[anObject.name applyFontTraits:NSBoldFontMask range:NSMakeRange(0, 14)];
[anObject.name endEditing];
下面是我如何设置单元格的值:
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
return [(AnObject*)item name]; //I ignored tableColumn as this is a 1 column outline.
}
单元格显示为普通文本,但用户可以将其编辑为粗体等。我想您可能不会返回与粗体创建的“草稿章节”相同的“草稿章节”。您是否检查了
objectValueForTableColumn
的返回值?谢谢。按照你的建议,我今天早些时候查过了。它仍然是一个属性字符串。在浪费了太多时间之后,我放弃了。