Reputation: 1506
I have a button that when clicked opens a Preferences window:
-(IBAction)openPreferences:(id)sender
{
if (!prefController) {
prefController = [[PreferencesController alloc] initWithWindowNibName:@"Preferences"];
[prefController showWindow:self];
}
}
However, upon closing the Preferences window, clicking on the button again does not re-open the window. Can someone teach me how to solve this? thanks xD
Upvotes: 1
Views: 294
Reputation: 89549
My original answer (which usually solves most of these kinds of issues)
Turn OFF the "Release When Closed" checkbox for that window in Interface Builder and you should be okay.
My answer #2)
Put that [prefController showWindow:self];
line OUTSIDE of the if (!prefController)
context (i.e. so that showWindow
gets called each time openPreferences
is called).
Or, to be more clear:
-(IBAction)openPreferences:(id)sender
{
if (!prefController) {
prefController = [[PreferencesController alloc] initWithWindowNibName:@"Preferences"];
}
[prefController showWindow:self];
}
Upvotes: 2