我正在使用doubleClickAction
aNSTableView
来显示 a NSPopover
。像这样的东西:
NSInteger selectedRow = [dataTableView clickedRow];
NSInteger selectedColumn = [dataTableView clickedColumn];
// If something was not selected, then we cannot display anything.
if(selectedRow < 0 || selectedColumn < 0)
{
NSLog(@"Invalid selected (%ld,%ld)", selectedRow, selectedColumn);
return;
} // End of something was not selected
// Setup our view controller, make sure if there was already a popover displayed, that we kill that one off first. Finally create and display our new popover.
DataInspectorViewController * controller =
[[DataInspectorViewController alloc] initWithNibName: @"DataInspectorViewController"
bundle: nil];
if(nil != dataPreviewPopover)
{
[dataPreviewPopover close];
} // End of popover was already visible
dataPreviewPopover = [[NSPopover alloc] init];
[dataPreviewPopover setContentSize:NSMakeSize(400.0f, 400.0f)];
[dataPreviewPopover setContentViewController:controller];
[dataPreviewPopover setAnimates:YES];
[dataPreviewPopover showRelativeToRect: [dataTableView frameOfCellAtColumn: selectedColumn row: selectedRow]
ofView: dataTableView
preferredEdge: NSMinYEdge];
哪个工作得很好。我的弹出框在我双击的单元格上创建和删除。问题是,如果我单击弹出框之外的任何位置(例如单击另一个单元格),我希望弹出框消失。我一直在环顾四周,但我一生都不知道该怎么做。
这是我假设内置在弹出窗口中的东西,(我相当肯定它在 iOSUIPopoverController
类中)所以我只是想知道我是否遗漏了一些简单的东西。