繁体   English   中英

添加自定义nsview

[英]Adding custom nsview

在Mac OS X中,我试图将自定义NSView添加到我的视图控制器中(我使用情节提要)

这就是我创建视图类的方式:

@interface Card1View : NSView

@end

和.m文件:

@implementation Card1View

-(instancetype)initWithFrame:(NSRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [[NSBundle mainBundle] loadNibNamed:@"Card1View" owner:nil topLevelObjects:nil];
    }
    return self;
}

@end

添加我正在使用的视图

NSView *view = [CardsProvider getCard:self.uxCardsView.frame];
[self.uxCardsView addSubview:view];

但这不起作用,我尝试了一些修改,但没有成功。 有什么想法我做错了吗?

请尝试加载笔尖代码移到里面ViewDidLoad的呼叫NSViewController

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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