Re: Newbie. Creating SubViews that aren't associated with NSWindow, or NSPanel?
Re: Newbie. Creating SubViews that aren't associated with NSWindow, or NSPanel?
- Subject: Re: Newbie. Creating SubViews that aren't associated with NSWindow, or NSPanel?
- From: Ken Thomases <email@hidden>
- Date: Wed, 10 Dec 2008 15:11:41 -0600
On Dec 10, 2008, at 2:50 PM, aaron smith wrote:
Hey All, this could be a newbie question, or a somewhat mid-level
question. Basically, I don't understand how I can create "views" that
aren't associated with an NSWindow, or NSPanel.
Here's a breakdown of what I'm trying to accomplish..
-I have a MainMenu nib.
-in that it has the usual 1 window.
-On the Window, I have a NSToolbar.
-The NSToolbar has 2 buttons (view1,view2) View 1 will be the default.
Now what I want to do is show/hide view1/view2 depending on which
button you click. What I'm confused about is achieving "tab" like
behavior, without using a tab view.
Why not use a tab view? You can configure its appearance to hide the
actual tabs, in which case it becomes a convenient control for
managing and switching amongst several views.
How do I go about create views separately, and attaching them to the
NSWindow, based on the toolbar buttons. I'm looking for is some
direction.
Here's kind of what I was thinking..
option 1. Create multiple NSWindows or NSPanels, for view1,view2. Use
the contentView property of those windows to attach to my main window
when you've clicked a toolbar button.
option 2. Use separate nibs for the views, each nib would be an
NSPanel. Then the main bundle loads those nibs in, attaches it's
contentView to the main bundle's main view.
Is this the right direction? I'd really appreciate some feedback.
Views don't need to be contained in a window in the nib. You can drag
a view from the library directly into the nib. You can then set up
outlets from, for example, File's Owner to these views to reference
them later in the code.
Depending on the design, all the views may be in the same nib as the
window or, if they are likely to be reused in other contexts, each
view can be put into its own nib which you'd use NSViewController to
load and own.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden