1

我自定义 NSTableView 就像我在 UITableView 中所做的一样。我实现了数据源和委托。在代码中,我这样做:


- (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 中一样进行自定义。问题是左右边框都有一条线,例如: 在此处输入图像描述

我尝试更改单元格视图的框架,它似乎没有用。由于这是在 iOS 中自定义单元格的正确方法,我想知道在 Cocoa 中哪里错了。

有谁能够帮助我?谢谢。

4

2 回答 2

4

最后,我发现它是Cell Space可以在笔尖中设置的。

于 2012-08-06T02:27:53.507 回答
0

在 iOS 中:

Tableviewcells 与 Tableview 相同。它们是自动调整大小的。如果您在 cellForRowAtIndexPath: 方法中为单元格设置框架,则不会更改任何内容。

对于宽度,您需要更改表格视图的宽度。对于高度,您需要实现 tableview 的委托方法 heightForRowAtIndexPath: 或设置 rowHeight 属性。

但是我不知道NSTableView怎么样,我觉得是差不多的。

于 2012-07-22T11:39:01.560 回答