Question

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.

Was it helpful?

Solution

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

OTHER TIPS

In iOS:

Tableviewcells have same with with Tableview. They are autoresized. If you set frame for a cell in cellForRowAtIndexPath: method, changes nothing.

For width you need to change the width of the tableview. For height you need to implement delegate method heightForRowAtIndexPath: of the tableview or set rowHeight property.

But I don't know how is it for NSTableView, I think it is similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top