objective-c - cocoa-如何用ViewController加载一个custom view
高洛峰
高洛峰 2017-05-02 09:21:44
0
1
510

我正在尝试着做一个状态栏应用。
AppDelegate中追踪鼠标动作。然后让nib对应的ViewController来调用加载view的函数。

//AppDelegate.h
@property myViewController *viewController;

//AppDelegate.m
@synthesize viewController;

- (IBAction)clickPreferences:(id)sender {
    [viewController showView:sender];
}

//myViewController.m
@property (strong) IBOutlet NSView *preferencesView;

-(void)showView:(id)sender{
        self.view = self.preferencesView; //here preferencesView is an IBOutlet property
    [self loadView];
}

错误信息:

-[myViewController loadView] loaded the "Preferences" nib but no view was set.

Preferences.xib中只有一个custom view。
我觉得应该不需要一个NSWindow。请问加载一个view需要哪些条件?如何调用?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
过去多啦不再A梦

What the hell are you talking about? Is this really iOS?
NSView is an object of Cocoa. How can it be iOS
Is UIView good?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template