I am trying to resize all the subviews inside my NSViewController when the NSWindow is resized.
The NSWindow view contains the NSViewController.view as a subview. I set autoResizing as YES as well as autoResizing masks to both horizontal and vertical.
[self.view setAutoresizesSubviews:YES];
[background setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
However, this technique didn’t work with me. Please note that all my components are added by code rather than using IB.
So my questions are:
- What should I add in order to make it auto resize?
- I use OpenGL to draw in another view. Do I need to do the calculations with respect to the new size? When I used cocos2d for another app, I didn’t have to worry about the calculations. So is there a similar thing here?
You need to set layout constraints on your UI components if you want them to respond to layout changes.
In IB there are defaults which will not be what you want but they are there to tweak.
Auto resize is a misnomer. Resize components according to their preset layout constraints would be a better but much longer name.
I guess there is no free lunch.