Cocoa window position anomaly
Posted
by Marius
on Stack Overflow
See other posts from Stack Overflow
or by Marius
Published on 2010-02-12T08:10:59Z
Indexed on
2010/03/12
7:07 UTC
Read the original article
Hit count: 273
Hello everyone,
I have a weird problem with positioning a window on screen. I want to center the window on the screen, but i don't know how to do that. Here's what i've got. The window is created from nib by the main controller:
IdentFormController *ftf = [[IdentFormController alloc] initWithWindowNibName:@"IdentForm"];
[[ftf window] makeKeyAndOrderFront:self];
Now the IdentFormController has awakeFromNib() method in which it tries to position the window. For the sake of simplicity i've just tried to do setFrameOrigin(NSMakePoint(0, 0)). What happens is as follows:
The first time i create this window, everything works as expected. But if i create it again after releasing the previous, it starts appearing at random positions. Why does it do that?
© Stack Overflow or respective owner