Window setTitle Ignored at Launch?
Window setTitle Ignored at Launch?
- Subject: Window setTitle Ignored at Launch?
- From: Chunk 1978 <email@hidden>
- Date: Fri, 6 Nov 2009 12:01:16 -0500
i'm following hillegass' "view swapping" (chapter 29), concerning the
NSViewController. i can successfully display the proper view at launch
(based on the index of an NSMutableArray), but i cannot set the window's
title using the same index? the window loads as "Untitled", which is it's
title in IB. the window's title only changes when the user chooses a new
view from the popup menu. what am i doing wrong?
- (void)displayViewController:(ManagingViewController *)vc
{
//Try to end editing
NSWindow *w = [box window];
BOOL ended = [w makeFirstResponder:w];
if (!ended)
{
NSBeep();
return;
}
//Put the view in the box
NSView *v = [vc view];
[box setContentView:v];
//-=-=-=-=-=-=-=-=-=-=-=-//
// CHANGE WINDOW'S TITLE //
//-=-=-=-=-=-=-=-=-=-=-=-//
[w setTitle:[NSString stringWithFormat:@"Application Mode: %@", [vc title
]]];
}
- (NSString *)windowNibName
{
return @"MyDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *)windowController
{
[super windowControllerDidLoadNib:windowController];
NSMenu *menu = [popUp menu];
int i, itemCount;
itemCount = [viewControllers count];
for (i = 0 ; i < itemCount ; i++)
{
NSViewController *vc = [viewControllers objectAtIndex:i];
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:[vc title] action:
@selector(changeViewController:) keyEquivalent:@""];
[mi setTag:i];
[menu addItem:mi];
[mi release];
}
[self displayViewController:[viewControllers objectAtIndex:0]];
[popUp selectItemAtIndex:0];
}
_______________________________________________
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