2

我在自定义 NSCell 中有一个 NSPopUpButtonCell 并且我正在使用

- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView

单击时生成弹出菜单。

我还覆盖了 copyWithZone: 在我的自定义单元格中复制 popUpCell 实例变量,以便我的表格视图中的每一行都有自己的弹出单元格。

My problem is that although the menu pops up just fine, and you can select an item from the menu, when an item is selected the cell does not change its selected item to match the chosen one from the menu.

但是,如果我用复制单元格的区域注释掉副本中的行,那么它会在选择过程中正常运行(更改以匹配所选项目,尽管每一行都将具有相同的所选项目)。

有谁知道这是为什么,或者更重要的是,我该如何解决?

4

2 回答 2

0

我建议不要复制单元格,而是使用:

- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex

...在绘制每一行之前使用正确数据设置单元格的委托方法。

于 2009-06-12T22:38:19.767 回答
0

您是否尝试过使用

–trackMouse:inRect:ofView:untilMouseUp: 

代替

startTrackingAt:inView:

?

于 2009-06-12T19:26:25.923 回答