strange quark
strange quark

Reputation: 5205

Cocoa sheet shows up in a random place

I'm trying to create a sheet that I'm loading from a custom nib file and has it's own Window Controller. In my app delegate upon a button press, I call

- (IBAction)loginLogout:(id)sender {
    if (![self isLoggedIn]) {
        // need to login
        LoginManager *manager = [[LoginManager alloc] initWithWindowNibName:@"LoginSheet"];
        [manager presentLoginWithWindow:self.window];
    }
}

Then in the window controller (the LoginManager class), I have this

- (void)presentLoginWithWindow:(NSWindow *)window {
    if (!self.window) {
        [NSBundle loadNibNamed:@"LoginSheet" owner:self];
    }

    [NSApp beginSheet:self.window modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil];
}

But I end up with this.

enter image description here

Upvotes: 0

Views: 199

Answers (1)

omz
omz

Reputation: 53561

Perhaps you left the sheet window's "Visible At Launch" option checked in Interface Builder?

Upvotes: 7

Related Questions