简体   繁体   中英

NSView subView not visible after added to superView

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?

baseView.needsDisplay = YES;

- 要么 -

subview.superview.needsDisplay = YES;

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM