I need to understand how NSView autoresizes it's views. I've set everything up in IB and my subviews resize nicely (when I resize my window around with a mouse). However, if I do [myMainView setFrame:]
with my new frame rect, nothing happens. All of my sub-views are still the original size (even though the main view has the correct dimensions). Child's resizeWithOldSuperviewSize:
gets called, but it's still not appropriately sized.
I have a screen-full of cocoa elements on screen (screen #1), label, image, video. There's a well-defined layout for these elements. I've setup autoresizing behavior via Interface Builder that works very well. Resizing the main window resizes the elements in a satisfying manner.
Now, the user clicks the "next" button, whereupon a second screenfull of elements (screen #2) is to be drawn. My layouts are built based on a canonical screensize (say, 800x600). But now the window is larger (or smaller) because it was resized in screen #1. So the elements are now only taking a small area in the window, instead of being appropriately sized to fill the available space. I want to scale these elements.
Am I misunderstanding how autoresizing works? How can I trigger the autoresize machinery underneath NSView manually?
There are two things I can do:
- Manually resize the elements based on the current screen size relative to original size. This option is not my favorite because seemingly, I'm forced to rewrite the code that's already working in NSView (the autoresizing behavior
- My second option is to invoke the aforementioned NSView's autoresizing magic. Documentation implies that [NSView setFrame:] will do that for me. What I've tried was, resize my content view to the original screensize (800x600), render my elements and then resize it to the current window size. Conceptually, is it not identical to manually resizing the window? It appears not to be. Again, this option is preferable because it minimizes the amount of code that has te be written and maintained.