【发布时间】:2011-12-18 21:26:34
【问题描述】:
我想创建一个主视图控制器来处理自定义导航栏及其行为。
然后,我想继承这个新类以使用它的行为并为我的每个 ViewController 链接一个“contentView”IBOutlet。
这是我的 BaseViewController.xib:
TestViewController.xib:为其父级链接“contentView”出口
TestViewController.h:继承自 BaseViewController
#import "BaseViewController.h"
@interface TestViewController : BaseViewController
@end
TestViewController.m:应该使用 TestViewController.xib 中的 outlet
- (id)init
{
self = [super init];
if (self) {
[[NSBundle mainBundle] loadNibNamed:@"TestViewController"
owner:self
options:nil];
}
return self;
}
显然,我希望 MainViewController 中的绿色条带有白色视图和 TestViewController 中的标签,但它实际上不起作用,结果如下:
如果在 TestViewController.xib 中,我将“视图”出口与视图链接,它实际上覆盖了这个屏幕,我没有来自 MainViewController 的绿色条,所以我猜我的导入工作正常,但我不能不明白为什么它不能与 contentView 一起工作。
有什么想法吗?
干杯!
西里尔
【问题讨论】:
标签: iphone ios uiviewcontroller xib subclassing