1

I want to put a attributed string on a nstextview, and manually calculate the height of the textview and row

-(CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row

inside

-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
    {
        WBMessageTableCellView *result = [tableView makeViewWithIdentifier:@"wbCell" owner:self];

        //do some calculation, and update textview's frame
        textView.frame = CGRectMake(57.0f, 36.0f-height, 380.0f, height);
    }

height is the calculated result for NSTextView.

everything is fine for the first time, enter image description here

but if I scroll, the TextView starts move down, enter image description here

it has been bugs me for a day, does anyone knows why? thanks in advance.

4

1 回答 1

0

我自己想办法。

答案是我需要覆盖prepareForReuse,并将单元格的框架重置为原始大小,所以计算很好。

于 2012-10-21T03:21:06.080 回答