Re: NSViewController and View Swapping
Re: NSViewController and View Swapping
- Subject: Re: NSViewController and View Swapping
- From: Brad Gibbs <email@hidden>
- Date: Sun, 13 Jul 2008 23:04:14 -0700
Thanks for the quick response and the links.
NSTabView with tabs on the bottom is exactly what I'm looking for,
except, I'm writing a fullscreen app with stylized NSImage buttons,
rather than tabs. I'm still looking through the ViewController sample
code. Given the number of single window apps out there today, it
seems like swapping views should be one of those common things that is
easy to accomplish with Cocoa, rather than an uncommon thing that's
merely possible...
On Jul 13, 2008, at 10:46 PM, Nathan Kinsinger wrote:
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