在基于视图的表中获取按钮的行 [英] Get button's row in view based table
问题描述
单击按钮后,如何在基于视图的表中获得按钮的行?单击该按钮时未选择该行,但是我发现,如果您在该按钮的操作方法中记录sender.superview.superview,则会得到:NSTableRowView:0x1001b3a90-第2行.因此,该行在日志中存在,但我不知道如何以编程方式进行操作.我在NSTableCellView的子类中有按钮的操作方法.
How do you get the row for a button in a view based table when you click the button? The row is not selected when the button is clicked, but I found that if you log sender.superview.superview in the button's action method, I get: NSTableRowView: 0x1001b3a90 - row: 2. So, the row is there in the log, but I don't know how to get at it programmatically. I have the button's action method in a subclass of NSTableCellView.
推荐答案
-[NSTableView rowForView:]
在其文档中表示:
对于NSButton(或NSControl),在action方法中通常需要这样做,以找出应在哪个行(和列)上执行操作.
This is typically needed in the action method for an NSButton (or NSControl) to find out what row (and column) the action should be performed on.
这篇关于在基于视图的表中获取按钮的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!