我有一个类,它是从具有所有功能的 xib 的窗口控制器派生的。在这个 xib 中,我有一个显示大厅列表的表格视图。如果我双击一个大厅名称,我会得到一个弹出框,显示该大厅的特征。我有一个视图控制器类,我会在其中以编程方式创建弹出窗口,
NSPopover *popover;
NSViewController *popoverViewController;
-(void)displayPopover{
popover = [[NSPopover alloc] init];
[popover setBehavior: NSPopoverBehaviorApplicationDefined];
[popover setDelegate: self];
popoverViewController = [[CHBPopover alloc] initWithNibName: @"MYViewController" bundle: nil];
[popover setContentViewController: popoverViewController];
[popover setContentSize: popoverViewController.view.frame.size];
[popover showRelativeToRect: NSMakeRect(700, 400, 5, 5)
ofView: [[NSApp keyWindow] contentView]
preferredEdge: NSMaxXEdge];
}
在我的窗口控制器类中,我有一个方法,例如,
-(IBAction)featuresDisplay:(id)sender{
if([_hallNamesList selectedRow] == -1){
[self setFeaturesList:nil];
}
else {
//[self.hallFeaturesPopOver showRelativeToRect:[_hallNamesList frameOfCellAtColumn:0 row:[_hallNamesList selectedRow]] ofView:_hallNamesList preferredEdge:NSMaxXEdge];
// [pop.displayPopover ];
NSDictionary *hallFeaturesDictionary;
hallFeaturesDictionary = [_hallNames objectAtIndex:[_hallNamesList selectedRow]];
_hallId=[hallFeaturesDictionary valueForKey:@"hallId"];
[officeDetails setHallName:[hallFeaturesDictionary valueForKey:@"hallName"]];
_featuresList=[conferenceHall getConferenceHallFeaturesWithDetails:officeDetails];
NSLog(@"features list=%@",_featuresList);
[self setFeaturesList:[conferenceHall getConferenceHallFeaturesWithDetails:officeDetails]];
}
}
我将如何在此 IBAction 中调用该弹出框方法?我需要双击一行并显示弹出窗口。我该怎么做?谢谢。