簡體   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