I'm pulling my hair out trying to figure why my views aren't resizing with my NSWindow on drag.
Okay, here's my structure:
I'm adding each of these views to my NSWindowController's Custom View. This is the only relevant method in my file:
-(void)setActiveView:(NSString*) viewString{
if ([currentViewController view] != nil)
[[currentViewController view] removeFromSuperview];
if ([viewString isEqualToString:kFirstView]){
FirstViewController *viewController = [[FirstViewController alloc]initWithNibName:kFirstView bundle:nil];
if (viewController != nil){
currentViewController = viewController;
}
}
else if ([viewString isEqualToString:kSecondView]){
SecondViewController *viewController = [[SecondViewController alloc]initWithNibName:kSecondView bundle:nil];
if (viewController != nil){
currentViewController = viewController;
}
}
//Resize Controller to Window's size.
[[currentViewController view] setFrame:[myWindowView bounds]];
//Embed current view into Custom View in host view.
[myWindowView addSubview:[currentViewController view]];
}
The setFrame to resize does work when I change views, but not when I drag to resize my window. As far as I can tell, because setFrame works when I change views, the only one that really matters (but isn't working) is the Custom View inside my NSWindowController.
Also, this is how I bring this window forward:
myController = [[MyWindowController alloc]initWithWindowNibName:@"MyWindow"];
[myController showWindow:nil];
Yes I've already tried in my initwithframe:
[myWindowView setAutoresizesSubviews:YES];
[myWindowView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
What am I missing?
Try to do this without Auto Layout.
Try this:
Uncheck Use Auto Layout for window.
Go to Size inspector and make autosizing to Your Views like this: