问题
this is my final window
i added 4 subviews (last 4 in 2nd image) to the base view. but not displaying the view. after manual resizing window the subviews appeared as below.
how can fix it?
回答1:
baseView.needsDisplay = YES;
-- or --
subview.superview.needsDisplay = YES;
回答2:
You can use NSScrollView:
NSScrollView* scrollView = [[NSScrollView alloc] init];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
self.contentView = [[NSView alloc] initWithFrame: NSMakeRect(0, 0, 1.0e7, 1.0e7)];
[self.contentView addSubview: [NSImageView ...]];
[self.contentView addSubview: [NSImageView ...]];
...
[scrollView setDocumentView: self.contentView];
self.view = scrollView;
Or use Minimum Size for Window.
来源:https://stackoverflow.com/questions/17691614/nsview-subview-not-visible-after-added-to-superview