如何在NSTableView中突出显示和编辑行(如SnowLeopard中的iCal)?

时间:2012-04-11 06:57:01

标签: objective-c cocoa nstableview

我想实现类似于iCal的实现。我想同时突出显示和编辑该行。我使用过cellBased tableview。我尝试了以下的事情。

 [self.tableView editColumn:0 row:[self.array count]-1 withEvent:nil select:YES];
 NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:[self.array count]-1 ];
 [self.tableView selectRowIndexes:indexSet byExtendingSelection:YES];

但是上面的代码突出显示了所有行但不是当前行。我想突出显示当前行并想要编辑相同的行。有任何提示可以实现这一目标吗?


我想实现一些与邮件类似的东西。单击项目时,该行应突出显示,textField应突出显示。我不需要左侧的图标。

1 个答案:

答案 0 :(得分:0)

Customized the TableViewCell and implemented the drawWithFrame.

-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
    NSRect newFrame = cellFrame;
    newFrame.origin.x += 50;
    newFrame.origin.y += 2;
    newFrame.size.height -=4;
    [super drawWithFrame:newFrame inView:controlView];
}

以下链接帮助我解决了这个问题。

http://developer.apple.com/library/mac/#samplecode/SourceView/Introduction/Intro.html