starting with nib of your .m file write
[Notification addObserver:self selector:@selector(screenResize) name:NSWindowDidResizeNotification object:nil];
and create a method
(void)screenResize { NSRect rect = Preloader.frame; rect = NSMakeRect(self.view.frame.origin.x+self.view.frame.size.width/2, self.view.frame.origin.y+self.view.frame.size.height/2, Preloader.frame.size.width, Preloader.frame.size.height); Preloader.frame = rect; NSLog(@"X = %f, Y = %f, W = %f, H= %f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); }
and when you exit this class write
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:nil];
NSparru
source share