我有一个 NSSplitView 作为我的“Superview”。在这个 SplitView 中是一个带有 NSTableView 的自定义视图。我正在尝试从 Controller 类加载我的自定义视图,然后调整自定义视图和表格的大小。但是表格和/或自定义视图不会调整大小。我做错了什么?
这是我的控制器类方法,我在其中加载并设置自定义视图的大小:
// Header File @property (weak) IBOutlet NSView *navigationView; @property (strong) AppsNavigationViewController *navigationViewController;
// Implementation
- (void) initNavigationView :(id)viewControllerClass :(NSString*) viewNibName {
_navigationViewController = [[viewControllerClass alloc]
initWithNibName:viewNibName bundle:nil];
// add the current custom view to the parent view
[_navigationView addSubview:[_navigationViewController view]];
[[_navigationViewController view] setAutoresizingMask:
NSViewHeightSizable|NSViewWidthSizable];
// set the bounds of the custom view to the size of the parent view
[[_navigationViewController view] setBounds:[_navigationView bounds]];
[_navigationViewController setDelegate:self]; // not relevant
[_splitView adjustSubviews]; // checked. contains the _navigationView
}
这是它的外观:
编辑 我对一些视图进行了子类化并绘制了不同的背景。而且绝对是自定义视图没有得到大小!