简体   繁体   中英

Adding custom nsview

In Mac OS X I'm trying to add custom NSView to my view controller (I'm using storyboard)

That's how I create view class:

@interface Card1View : NSView

@end

and .m file:

@implementation Card1View

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

@end

to add this view I'm using

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

But it doesn't work, I tried some modifications but without success. Any ideas what am I doing wrong?

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

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