2012-07-22 26 views
1

我自定義NSTableView就像我在UITableView中做的一樣。我實現了數據源和委託。在代碼中,我喜歡這樣的:自定義NSTableViewCell


- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row 
{ 
    ZJCellView *cellView = [tableView makeViewWithIdentifier:cellIdentifier owner:self]; 
    //this is a custom view 
    if (cellView == nil) 
    { 
     CGRect rect = CGRectMake(0, 0, tableView.frame.size.width, kTableViewCellHeight); 
     cellView = [[[ZJCellView alloc] initWithFrame:NSRectFromCGRect(rect)] autorelease]; 
     cellView.identifier = cellIdentifier; 


     // some other controls 

    } 
    return cellView; 

我這樣做的習慣就像我在iOS中做的一樣。 問題是存在於左,右一個邊界,如: enter image description here

我試圖改變細胞視圖的框架,它似乎是沒有用的。 因爲這是在iOS中定製單元格的正確方式,所以我想知道Cocoa中它錯誤的位置。

任何身體能幫助我嗎? 謝謝。

回答

4

最後,我發現它是Cell Space它可以在筆尖中設置。

0

在iOS系統:

Tableviewcells有相同帶泰伯維。他們是自動化的。如果您在cellForRowAtIndexPath:方法中爲單元格設置了框架,則不會進行任何更改。

對於寬度,您需要更改tableview的寬度。 對於高度,您需要實現tableview或set rowHeight屬性的委託方法heightForRowAtIndexPath:。

但我不知道它是如何爲NSTableView,我認爲它是相似的。

+0

我已經用tableview的寬度初始化單元格視圖。問題存在。 – scorpiozj 2012-07-22 11:50:30