我想創建一個主視圖控制器來處理自定義導航欄及其行爲。子類化一個主視圖控制器與插座
然後,我想繼承這個新類以使用它的行爲併爲我的每個ViewController鏈接一個「contentView」IBOutlet。
這裏是我的BaseViewController.xib:
TestViewController.xib:鏈接 「內容查看」 出口其父
TestViewController.h:從BaseViewController
#import "BaseViewController.h"
@interface TestViewController : BaseViewController
@end
繼承TestViewController.m:應該使用來自TestViewController.xib的插座
- (id)init
{
self = [super init];
if (self) {
[[NSBundle mainBundle] loadNibNamed:@"TestViewController"
owner:self
options:nil];
}
return self;
}
很明顯,我想有從MainViewController綠色地址欄與白的觀點,並從TestViewController的標籤,但它實際上沒有工作,這裏是結果:
如果TestViewController.xib,我將視圖鏈接到一個視圖,它實際上覆蓋了這個屏幕,而且我沒有MainViewController的綠色條,所以我猜我的導入工作正常,但我不明白爲什麼它不能處理contentView 。
有什麼想法?
乾杯!
Cyril