我创建一个XIB.
我创建了这个名为的类MyCustomView并将其分配给XIB's File Owner。
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) [self load];
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) [self load];
return self;
}
- (void)load {
NSArray* topLevelObjects;
[[NSBundle mainBundle] loadNibNamed:@"MyCustomView"
owner:self
topLevelObjects:&topLevelObjects];
NSView* view;
for (id aView in topLevelObjects) {
if ([umaVista isKindOfClass:[NSView class]]) {
view = umaVista;
break;
}
}
[self addSubview:view];
view.frame = self.bounds;
}
NSView我在主应用程序上创建了一个。
我将该视图更改为MyCustomView.
我运行应用程序。MyCustomView的initWithCoder不运行。initWithFrame不运行。awakeFromNib不运行。
什么都没发生。
有任何想法吗?