【发布时间】:2017-03-30 15:36:55
【问题描述】:
我在 Mac 中设置 NSTextFieldCell 的框架时遇到问题。我的NSTextFieldCell 位于列的 (0,0) 点。我需要在 y 位置有 4px 的间隙。下面是现有 UI 的图片。
这是.xib结构的样子:
我试图设置框架的委托方法如下:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)aRow
{
if ([[aTableColumn identifier] isEqualToString:@"notes"])
{
[aCell setBackgroundColor:[NSColor redColor]];
NSTextFieldCell *theCellView = aCell;
NSView *controlView = [theCellView controlView];
NSRect frame = controlView.frame;
frame.origin.x = 120;
frame.origin.y = 130;
[controlView setFrame:frame];
}
}
【问题讨论】:
-
表格视图应该是基于视图还是基于单元格?
-
谢谢@Willeke。它是基于细胞的。
-
cell的controlView为table view。
标签: objective-c macos nstableview nstextfield