我定制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中哪里错了。
有人能帮我吗?谢谢。
发布于 2012-08-06 10:27:54
最后,我发现可以在nib中设置的是Cell Space。
发布于 2012-07-22 19:39:02
在iOS中:
Tableview单元格具有与Tableview相同的。它们是自动调整大小的。如果在cellForRowAtIndexPath: method中为单元格设置了frame,则不会更改任何内容。
对于宽度,您需要更改表视图的宽度。对于height,需要实现tableview的委托方法heightForRowAtIndexPath:或者设置rowHeight属性。
但我不知道NSTableView是怎么回事,我想它是相似的。
https://stackoverflow.com/questions/11599755
复制相似问题