NSView subView not visible after added to superView

£可爱£侵袭症+ 提交于 2019-12-12 01:28:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!