简体   繁体   中英

NSPopover and Snow Leopard

I've implemented a NSPopover in my Mac app. It works great in 10.7 Lion, but crashes when launching in 10.6 Snow Leopard. I know that support for NSPopover were introduced in Lion and isn't supported in 10.6, but I would like to know how to make my app compatible with the good old' Snow Leopard.

I'm pretty new to Mac development, but here is the code. Any tips? (The popover is located in MainWindow.xib)

.h

NSPopover *popOver;
@property (assign) IBOutlet NSPopover *popOver;
- (IBAction)showPopover:(id)sender;

.m

- (IBAction)showPopover:(id)sender
{    

if (popOver.isShown) {

    [self.popOver close];
}

[[self popOver] showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge];    
}

在你的程序中使用MAAttachwindow并尝试

检查MAC OS版本( 链接 ),如果它是10.6使用NSDrawer,否则使用NSPopover。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM