Re: NSViewController and View Swapping
Re: NSViewController and View Swapping
- Subject: Re: NSViewController and View Swapping
- From: Brad Gibbs <email@hidden>
- Date: Mon, 14 Jul 2008 07:26:52 -0700
OK, thanks for the tip. I think this will work well for the situation
I described.
But, that screen (with its tab view and all of the custom views to be
made available from within the tab view) is one of several screens
like it. The other tab views will contain different numbers of tabs.
The user will be able to choose among the screens from a pop-up menu
on a status bar at the top of the screen. So, I still need a way to
swap out one set of tab views with another, without using a box, in a
non-document-based application. So, I think I still need to solve the
problem of how to change:
[box setContentView:v]
to swap out one custom tab view with another, so that when the user
selects another set of tab views, the current tab view is swapped out
and replaced by the newly-selected tab view.
Thanks again.
Brad
On Jul 14, 2008, at 12:17 AM, Scott Anguish wrote:
you can still do it with NSTabView
use setTabViewType to one of the following
NSNoTabsBezelBorder = 4, NSNoTabsLineBorder = 5, NSNoTabsNoBorder = 6
have your button actions change the visible tab using one of...
- (void)selectTabViewItemAtIndex:(NSInteger)index
- (void)selectTabViewItemWithIdentifier:(id)identifier
- (void)selectTabViewItem:(NSTabViewItem *)tabViewItem
On 14-Jul-08, at 2:04 AM, Brad Gibbs wrote:
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
_______________________________________________
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