开发者

Why isn't my subview loading?

开发者 https://www.devze.com 2023-04-03 09:06 出处:网络
I have a project with 3 .xib files, MainMenu, FileUploadView, FileBrowseView. MainMenu has a NSPanel, it\'s owner is AppDelegate, and AppDelegate has an outlet to NSPane开发者_开发技巧l called FileP

I have a project with 3 .xib files, MainMenu, FileUploadView, FileBrowseView.

  • MainMenu has a NSPanel, it's owner is AppDelegate, and AppDelegate has an outlet to NSPane开发者_开发技巧l called FilePanel. The NSView below the NSPanel is called filePanelView and also has an outlet in AppDelegate.

  • FileUploadView is an NSView, it's owner is FileUploadViewController. It has an outlet called uploadView in the controller.

  • FileBrowseView is similar, owner is FileBrowseViewController, has an outlet called browseView.

So in App delegate I have the following code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    fileBrowseViewController = [[FileBrowseViewController alloc]
        initWithNibName:@"FileBrowseView" bundle:nil];  
}

- (IBAction)importHandsClicked:(id)sender {
    [NSApp activateIgnoringOtherApps:YES];
    [filePanel setIsVisible:YES];
    [filePanelView addSubview:[fileBrowseViewController browseView]]; 

}

The action does make filePanel visible, but it doesn't add the browseView to it. Am I doing something wrong?


Check that [fileBrowseViewController browserView] is not nil.

This is highly probably, especially if you forgot or failed to link your browseView IBOutlet to the actual UIView that represents your FileBrowseView instance in InterfaceBuilder.

[EDIT] For more info about connecting outlets, see Apple's InterfaceBuilder Help here (including tutorial video).

0

精彩评论

暂无评论...
验证码 换一张
取 消