2013-10-07 18 views
-2

我正確地得到選定的行號,但所選列返回-1。selected NSTableView中的列返回-1

- (void) tableViewSelectionDidChange:(NSNotification *)notification 
{ 
    int row = [[notification object] selectedRow]; 
    int column = [[notification object] selectedColumn]; 
+0

你是如何選擇行?因爲-1的值表示沒有選擇列。 – Abizern

回答

0

第一件事tableviewselectiondidchange將始終爲您提供選定的行索引。您可以在NSTableviewdelegate參考方法中看到。如果你想要行和列索引,然後使用這個api

- (BOOL)tableView:(NSTableView*)tableView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row 
+0

非常感謝。 – user2855280