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

Discussion in 'Mac Programming' started by Virtualball, Feb 19, 2007.

  1. macrumors 6502

    Is there a way? Please help again :p
  2. Moderator


    Staff Member

    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.
  3. macrumors 6502

    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:

    Alpha Internet support:
    Normal Window (before I made it have the buttons)
    When you spin it:

    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
  4. Moderator


    Staff Member

    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.
  5. macrumors 6502

    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!
  6. macrumors 6502

    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 :)
  7. Moderator


    Staff Member

  8. macrumors 6502

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

Share This Page