How to close a view when one is opened?

Discussion in 'Mac Programming' started by goodrunb, Jan 2, 2010.

  1. goodrunb macrumors newbie

    Apr 13, 2009
    Ok, So A friend has an app, and I am helping program it for him.

    He has an app that is quartz composer based, but that has nothing to do with what I'm trying to accomplish.

    So He has a view when the app first opens. I created a drop down menu to open another view, but when it switches to that view both of the views are still there. I want to know how to make it to where when it switches to the 2nd view the first one closes. Also there is 6 views in all. I want to make it to where he can switch to any one view and the previous one he was viewing would close.

    Also, how do i make it to where when it switches to another view, in the dropdown menu it has a little tick by the view. I want to know how to make it tick based on which view is active.

    Ok thanks and I need help urgent! THANKS :D :apple::apple::apple::apple::apple::apple::apple::apple::apple::apple::apple::apple:
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Assuming you're doing this in Xcode/IB, do you know any Cocoa? IB can let you display Quartz Composer views without any code, but what you want to do requires actual programming.
  3. goodrunb thread starter macrumors newbie

    Apr 13, 2009

    I know the very basics of cocoa, but nothing more.

    And as far as IB, quartz composition picker doesn't require any code?
  4. Sydde macrumors 68020


    Aug 17, 2009
    If you are using NSView objects, you should be able attach all of the ones you want right where you want them (in a superview, such the window's content view) and simply use the method -setHidden: to toggle amongst them. According to the documentation, when a view is hidden, it is removed from the responder chain, but continues to receive resizing messages, according to its auto-resize mode. This is probably the simplest, fastest way to do what you want.
  5. Catfish_Man macrumors 68030


    Sep 13, 2001
    Portland, OR
    An NSTabView with tabs hidden is a typical way to accomplish view switching.
  6. GorillaPaws macrumors 6502a


    Oct 26, 2003
    Richmond, VA
    Just to extend this point a bit. You need an object that will act as the controller for those views (think "C" in MVC). Each view may have it's own view controller, but the superview's window controller should be managing the the creation/destruction, hiding/showing of it's subviews. Take a look at the Apple Docs on the view hierarchy.

Share This Page