Autosizing Multiple Views in a Window
Most windows that contain scrollers should be resizable. In Chapter 10, we showed how to set up an NSScrollView so that it would resize when its containing window was resized. Recall that we set the Autosizing attributes for the NSScrollView in IB’s Size Info dialog. That was easy to do for our MathPaper application because there was only one view — the NSScrollView — that covered the window’s content area. With the ViewDemo window, however, handling window resizing requires a little more thought because there are multiple view objects. Let’s first see what the current situation is.
Back in IB with PolygonView, choose the File → Test Interface menu command.
Resize the window up and to the left. Note that the view objects in the window don’t change size and thus become obscured when the window is small, as shown in the window on the left in Figure 15-11.
Figure 15-11. Problems with resizing in ViewDemo
Now resize the window down and to the right, and note that the objects still don’t change size or position relative to the lower-left corner. The result is ugly, as shown in the window on the right in Figure 15-11.
Quit Test Interface mode by typing Command-Q.
Select the NSScrollView/PolygonView instance and type Command-3 to bring up IB’s Size Info dialog with the Autosizing feature.
Click the lines in the inner Autosizing square so that the four ...