Obj C - Resizing Window Removes Window Items

2019-09-01 06:13发布

When I try to resize a window after a button is pressed, everything inside the window disappears and I believe it has to do with the origin of the window.

    NSRect frame = sender.window.frame;    
float d; //how much the window is changing
NSLog(@"the frame origin of y = %f", frame.origin.y);
d = (frame.size.height - 115);
NSLog(@"d variable = %f.", d);
frame.origin.y += d;
NSLog(@"the frame origin of y = %f", frame.origin.y);
frame.size.height = 115;
[sender.window setFrame:frame display:YES animate:YES];

The window is supposed to change its height to 115 and to ensure the top bar stays in the same place, the origin.y is adjusted however much the height had to change, yet when I test this, the top bar stays in the same place, but all the items inside the window disappear.

0条回答
登录 后发表回答