Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dynamically loading NIB files into sheets

Dynamically loading NIB files into sheets
Thread Tools
Mac Enthusiast
Join Date: Mar 2001
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Apr 13, 2002, 03:54 PM
 
Does anyone know how to dynamically load NIB files so that I can use them as sheets? This has been giving me a lot of trouble...

Here is what I want to do...

I have an Document-Based Cocoa application that has an NSPopUpButton with n different choices and a normal button next to it. When the normal button is pushed, I want it to check the NSPopUpButton and display a specific sheet depending upon which item in the NSPopUpButton is selected. I want the NIB file to be dynamically loaded since there are going to be a lot of them.

I've thought about creating a SheetController class that each Document has an instance of, and then having this SheetController class have instances of SheetControllerA, SheetControllerB, and so on for the number of sheets I have... but I'm having trouble implementing it (specifically with the syntax of the method that is called to display the sheet).

Can anyone help me?


Crunch Something
     
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Apr 15, 2002, 09:43 AM
 
I have an app which, when buttons are pushed loads sheets, each of which have their own nib file. I made instances of the classes in IB and hooked the buttons up to the appropriate actions. I don't know if this is the best way to do it, but it works. This is an example of how I did it with Java:

public void openSheet(NSButton aButton) { //this action was hooked up in IB

NSApplication.loadNibNamed("theSheet", this); //this loads the nib file
makeSheetAppear(); //this is the method that actually makes the sheet appear

}

public void makeSheetAppear() {
NSWindow theWindow = NSApplication.sharedApplication().keyWindow();
NSApplication.sharedApplication().beginSheet(sheet Window,theWindow,null,null,null);


}


Hope that helps.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:45 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2