Search code examples
cocoanstableviewnstableviewcell

custom NSTableViewCell


I custom NSTableView just like what I do in UITableView. I implement the datasource and delegate. In the code, I do like this:


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

I do the custom just like what I do in iOS. The problem is there is a line in both left and right border, like: enter image description here

I tried change the frame of the cell view and it seems to be of no use. As it is the right way to custom the cell in iOS, I wonder where is it wrong in Cocoa.

Can any body help me? thanks.


Solution

  • Finally, I find it is the Cell Space which can be set in the nib.