如何在 Xcode 6.3 OS X10.10 中制作 NsPopover objective C

How to make NsPopover in Xcode 6.3 OS X10.10 in objective C

我是一名新开发人员,我正在尝试在单击按钮时开发 Nspopover,但我没有获得相关资源,所以在 XCode 6.3 中我应该怎么做。

https://developer.apple.com/library/mac/samplecode/Popover/Listings/MyWindowController_m.html

顺便说一句,如果你自己搜索会更快"nspopover site:developer.apple.com/library/mac/samplecode"

@property (weak) IBOutlet NSViewController *popoverViewController;

// -------------------------------------------------------------------------------
//  showPopoverAction:sender
// -------------------------------------------------------------------------------
- (IBAction)showPopoverAction:(id)sender
{
    [self createPopover];

    NSButton *targetButton = (NSButton *)sender;

    // configure the preferred position of the popover
    NSRectEdge prefEdge = popoverPosition.selectedRow;

    [self.myPopover showRelativeToRect:[targetButton bounds] ofView:sender preferredEdge:prefEdge];
}


// -------------------------------------------------------------------------------
//  createPopover
// -------------------------------------------------------------------------------
- (void)createPopover
{
    if (self.myPopover == nil)
    {
        // create and setup our popover
        myPopover = [[NSPopover alloc] init];

        // the popover retains us and we retain the popover,
        // we drop the popover whenever it is closed to avoid a cycle
        //
        // use a different view controller content if normal vs. HUD appearance
        //

        self.myPopover.contentViewController = popoverViewController;

        // AppKit will close the popover when the user interacts with a user interface element outside the popover.
        // note that interacting with menus or panels that become key only when needed will not cause a transient popover to close.
        self.myPopover.behavior = NSPopoverBehaviorTransient;
    }
}