Re: NSViewController and View Swapping
Re: NSViewController and View Swapping
- Subject: Re: NSViewController and View Swapping
- From: Nathan Kinsinger <email@hidden>
- Date: Sun, 13 Jul 2008 23:46:15 -0600
On Jul 13, 2008, at 11:15 PM, Brad Gibbs wrote:
I'm trying to create a Cocoa app with a single window with a number
of views that get swapped in and out, using an NSViewController for
each of the views.
I have a series of buttons along the bottom of the UI in a custom
view, and another custom view above the row of buttons. When button
A is pressed, view A should appear in the custom view above the row
of buttons, and button A should be turned on. When button B is
pressed, view A should be replaced by View B, button A should turn
off and button B should turn on. Ultimately, I'd like to do this
with an animation (view A fades out and view B fades in). For now,
I'd be happy just replacing A with B.
I haven't been able to find much in the documentation about
NSViewController for Cocoa. I have the Hillegass book, but the view
swapping example in Chapter 29 is done with a document-based
application and the views there are contained in an NSBox:
...
NSView *v = [vc view];
[box setContentView:v];
...
I don't know Cocoa well enough to adapt this example for a non-
document-based application without an NSBox. Could someone please
point me to documentation for NSViewController, other than the
NSViewController Reference, or provide me with a quick explanation
or example code that will do this? I've read through the Katidev
blog on XSViewController and XSWindowController, but, again, that's
a document-based example, and it doesn't explicitly provide methods
for replacing one view with another.
Thanks in advance.
Brad
There is an example at:
http://developer.apple.com/samplecode/ViewController/index.html
Also what you are describing sounds a lot like an NSTabView with the
style set to Bottom Tabs. Try creating one in IB and playing with it.
Also look at:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TabView/TabView.html
and an example with animation at:
http://developer.apple.com/samplecode/Reducer/index.html
--Nathan
_______________________________________________
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