1. 首先注冊窗體大小變化時的事件處理的通知函數
[cpp]
[[NSNotificationCenter defaultCenter] addObserver:window
selector:@selector(windowDidResize:)
name:NSWindowDidResizeNotification
object:self];
2. 然後在定義的處理函數windowDidResize中調整window上面視圖的frame
[cpp]
- (void)windowDidResize:(NSNotification *)aNotification
{
// 調整NSWindow上NSView的frame
}
3. 實現NSView的函數resizeSubviewsWithOldSize
當在windowDidResize中修改NSView的fame時,這個函數會被調用。
[cpp]
- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize
{
// 根據需要調整NSView上面的別的控件和視圖的frame
}