1
我正在嘗試使用CTFramesetterSuggestFrameSizeWithConstraints()和tableview:heightOfRow :,提供帶有NSTableView的單元屬性的屬性字符串。的問題是,它的返回中的13.0倍數的值(13.0 1線,26.0兩行,等等)的,而不是14.0預期的倍數(其對應的爲[的tableView rowHeight的]。CTFramesetterSuggestFrameSizeWithConstraints()在表視圖中每行偏離1點
NSDictionary * attributes = [[[[[tableView tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
attributesAtIndex: 0 effectiveRange: NULL] retain];
NSAttributedString * attributedMessage = [[NSAttributedString alloc] initWithString: message attributes: attributes];
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attributedMessage);
CFRange range;
CGSize size = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, [attributedMessage length]), NULL, CGSizeMake([column width], CGFLOAT_MAX), &range);
CFRelease(framesetter);
[attributedMessage release];
return size.height;
任何意見將現在我正在硬編碼每行增加一點(13.0),但我想這樣做是正確的方式。