问题
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.
来源:https://stackoverflow.com/questions/9920025/obj-c-resizing-window-removes-window-items