【问题标题】:Adding custom nsview添加自定义nsview
【发布时间】:2015-02-03 16:15:57
【问题描述】:

在 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];

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

【问题讨论】:

    标签: macos nsview osx-yosemite


    【解决方案1】:

    请尝试将加载 nib 代码移动到 NSViewControllerViewDidLoad 调用内部。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2017-12-09
      • 1970-01-01
      • 2011-11-15
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多