Change the window frame and view frame at the same time

In my application, the user can press a key to switch between large and small window sizes. With a small size, the window is just enough to contain a certain look. With large sizes, the view becomes larger, while maintaining its aspect ratio, so that the view ends as high as the window, but not as wide. With a large size, the view should be centered in the window.

Now I am doing this in 2 stages: (1) resize the window, (2) resize and move the view. However, the user can see that these two steps occur one after the other, and not simultaneously. Is there a way to make NSWindow and NSView change or move at the same time? Or in some other way to solve this problem?

+4
source share
1 answer

A very easy way to do this is to use NSWindow disableScreenUpdatesUntilFlush . You would use it as follows:

- (void) toggleWindowSize { [ [ myView window ] disableScreenUpdatesUntilFlush ]; // Do stuff to change the size of the window and view. } 
+1
source

All Articles