hollow7
hollow7

Reputation: 1506

Preferences window does not re-open once closed

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

Answers (1)

Michael Dautermann
Michael Dautermann

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.

enter image description here

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

Related Questions