Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jinksys

macrumors newbie
Original poster
Dec 16, 2008
13
0
Saint Louis, Mo
This is what I have: Essentially the 'cocoa application' template with an AppController (NSObject) class added on. The AppController has been put in the main menu nib. The application loads a pdf into a pdfview (this part works), however I have a problem. I don't want the blank window to be shown at startup, and I also want to be able to recreate the window if another pdf is chosen after the window is closed. I have a (IBOutlet) NSWindow *window pointing to the window in the mainmenu.nib, and that connection is OK because I am able to zoom the window. I have a openPDFDialog method that is bound to the Open menuitem. In this method a NSopenpanel is used and pdfview is loaded with the pdfdocument. However, I can't get the window to show.

note: I am able to zoom the window if i let the window open at launch.
 
is the pdf window part of the same nib as the main application?
if it's in it's own nib then you can use the NSWindowController

otherwise you have to take that window in IB uncheck visible at launch in the inspector and also uncheck Release When Closed

then in your program hook up an IBAction method with this:

Code:
[myPDFWindow makeKeyAndOrderFront:self];
where myPDFWindow is the instance of the window in IB

it's probably a bad way of doing it but no one has said otherwise, it's probably best to use the NSWindowController and figure out how to link the nibs and xibs together some other way if they need to be
 
Thanks! I've got it working now. My program only has one window, which resides in the mainmenu.xib file. The program is only supposed to have one window open at a time so I figured using NSWindowControllers would have been overkill for this project. Your solution worked, thanks again!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.