objective-cosx类继承

objective-cosx类继承,objective-c,Objective C,我在“导航”类中有一个方法“ShowPop:nil”——它显示一个popover 我从AppDelegate.h继承了导航类。当我从AppDelegate.m调用[Self ShowPop:nill]时,popover不会弹出,但该方法会运行 请注意,我知道popover方法是有效的,因为它完全可以从同一方法的IB按钮连接中弹出 下面是示例代码 @interface Navigation_Main : NSObject { } @property (weak) IBOutlet NSPo

我在“导航”类中有一个方法“ShowPop:nil”——它显示一个popover

我从AppDelegate.h继承了导航类。当我从AppDelegate.m调用[Self ShowPop:nill]时,popover不会弹出,但该方法会运行

请注意,我知道popover方法是有效的,因为它完全可以从同一方法的IB按钮连接中弹出

下面是示例代码

@interface Navigation_Main : NSObject
{
}
    @property (weak) IBOutlet NSPopover *popover_AddStuff;
    - (IBAction)ShowPop:(id)sender;

- (IBAction)ShowPop:(id)sender;
{
    [_popover_AddStuff showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge];
}

**#导入“Navigation_Main.h”**
@接口AppDelegate:Navigation\u Main
{
-(iAction)showPopup:(id)发送方;
}
-(iAction)showPopup:(id)发送方{
//[self ShowPop:nil];---没有pop
[超级流行音乐:无];---没有流行音乐
}

nspover在positioning视图为nil时引发异常,因此不会显示popover。确保传递要相对于而不是零显示的popover视图

**#import "Navigation_Main.h"**
@interface AppDelegate : Navigation_Main <NSApplicationDelegate,NSTextFieldDelegate>
{
    - (IBAction)showPopup:(id)sender;
}

- (IBAction)showPopup:(id)sender {
    //[self ShowPop:nil]; ---No pop
    [super ShowPop:nil];  ---No pop
}