我正在使用NSTableView的doubleClickAction来显示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];
哪个工作很好.我的popovers被创建并删除在我双击的单元格.问题是,如果我点击它之外的任何地方(如单击另一个单元格),我想让popover离开.我一直在环顾四周,但是对于我来说,我的生活无法弄清楚如何做到这一点.
这是我会认为是建立在一个popover,(我相当确定它是在iOS UIPopoverController类),所以我只是想知道如果我缺少一些简单的东西.