2012-09-06 26 views
1

我想提出一個屬性串上nstextview,並手動計算的TextView的高度和行NSTextView框架問題裏面NSTableView的

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

-(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); 
    } 

高度的計算結果NSTextView。

一切都很好,第一次, enter image description here

,但如果我滾動,TextView的開始下移, enter image description here

它一直是我的錯誤了一天,沒有人知道這是爲什麼?提前致謝。

回答

0

我自己弄明白了。

答案是我需要重寫prepareForReuse,並將單元格的框架重置爲原始大小,因此計算結果很好。