UIViewParent中父级的LoadNib - UIViewChild关系

时间:2016-09-23 11:46:39

标签: ios objective-c uiview xib nib

我们假设我们有两个班级

UIViewParent :UIView
UIViewChild : UIViewParent

以及UIViewParent.xib

如何加载UIViewChild usig UIViewParent.xib

到目前为止,我试过了:

UIViewChild *view = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([UIViewParent class]) owner:self options:nil] firstObject];

但是我无法调用UIViewChild方法,它被标识为UIViewParent类。

@Edit

@interface UIViewParent : UIView
@end

@interface UIViewChild : UIViewParent
- (void)someChildMethod;
@end

@implementation UIViewChild
- (void)someChildMethod{}
@end

UIViewParent.xibUIViewParent class

现在ViewController中的某个地方我正在尝试:

//Here is question HOW to get view with Parent.xib
UIViewChild *view = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([UIViewParent class]) owner:nil options:nil] firstObject];

[view someChildMethod]; //Crash because view is identified as UIViewParent not UIViewChild
[self.stackView addArrangedSubview:view];

我不知道如何更简单地描述它。

0 个答案:

没有答案