PDA

View Full Version : Is there a way to launch a NIB and close the current one at the same time?




Virtualball
Feb 19, 2007, 12:25 PM
Is there a way? Please help again :P



robbieduncan
Feb 19, 2007, 02:04 PM
You can't launch a nib. They are not executable.

I assume you mean something along the lines of: can I load an NSWindow that is serialised in another Nib and close the current key window? If so not is a single line of code. Assuming you are doing things correctly and each Nib has a single Window in it and a NSWindowController subclass as it's owner then you can simply create an instance of that NSWindowController subclass with the correct nib name and ask it to display it's window.

Note doing this in an action (something like -(IBAction) doSomething:(id) sender) could be a bad idea unless you have some safe, sensible way to clean up that instance once you are done with it.

If you gave us some more concrete code to work from we might be able to give you some advice.

Virtualball
Feb 19, 2007, 05:57 PM
Well, to be honest, I am working on an iPhone app (Don't sue me Apple, pleaseeee :P) And I want it so when you click one of the invisable buttons on the screen, it opens up another window in it's same place and closes the main window. I have it so it opens up another window but it doesn't close the other one. Plus, its kinda a crappy "hack" (term to describe "thrown together poorly", right?). If you open the window, you can no longer quit anymore :rolleyes:


Here are screen shots:

E-mail:
http://img510.imageshack.us/my.php?image=picture24zv3.jpg
Alpha Internet support:
http://img476.imageshack.us/my.php?image=picture23eb3.jpg
Normal Window (before I made it have the buttons)
http://img405.imageshack.us/my.php?image=picture1fk0.jpg
When you spin it:
http://img405.imageshack.us/my.php?image=picture2jb7.jpg

It, at the moment, goes online, sends emails, has notes, uses the isight, and spins 90. But that isn't any good if I can't get my problem resolved :P

robbieduncan
Feb 20, 2007, 02:24 AM
1) Apple are going to send you a cease and desist letter as soon as they see this. All of the images they used on the iPhone are copyright as is the overall design.

2) You are doing this completely the wrong way if each of those screenshots is a separate Window in a new nib. Create 1 nib that has a custom NSWindow subclass as it's window. Override the draw methods to draw you custom iPhone border as the Window border and use a series of custom views for the centre part of the iPhone (the screen). You can just swap the views in and out as you change modes.

Virtualball
Feb 20, 2007, 11:00 AM
1) Apple are going to send you a cease and desist letter as soon as they see this. All of the images they used on the iPhone are copyright as is the overall design.

2) You are doing this completely the wrong way if each of those screenshots is a separate Window in a new nib. Create 1 nib that has a custom NSWindow subclass as it's window. Override the draw methods to draw you custom iPhone border as the Window border and use a series of custom views for the centre part of the iPhone (the screen). You can just swap the views in and out as you change modes.

1) Yeah.... but it's just for fun, I hope they'd understand that, look at iSoftPhone and iPhone countdown widget, they use the design!

3) Thanks!

Virtualball
Feb 20, 2007, 09:23 PM
Ok, last thing, I promise :)

I searched all over for a way to switch tabs without the buttons, but I haven't found a way. Can you provide a hint or some sample code? I'm stuck and I can't move further with my app :(

The tabview is named tabs and the identifiers are 1 2 3 and 4. Please help :)

robbieduncan
Feb 21, 2007, 04:00 AM
Sample code is not the documentation. I'd start by reading the documentation for NSTabView (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html) in particular selectTabViewItemWithIdentifier: (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTabView/selectTabViewItemWithIdentifier:).

Virtualball
Feb 21, 2007, 07:33 AM
Sample code is not the documentation. I'd start by reading the documentation for NSTabView (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html) in particular selectTabViewItemWithIdentifier: (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTabView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSTabView/selectTabViewItemWithIdentifier:).

Thats exactly what I wanted, thanks, you're awsome!!