我检查了KalViewController类。它没有initWithCoder:
的实现,如果从nibs/storyboards实例化的话,这个初始化器会被调用。
我说这个,使其工作:
-(id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder])) {
NSDate *date = [NSDate date];
logic = [[KalLogic alloc] initForDate:date];
self.initialDate = date;
self.selectedDate = date;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(significantTimeChangeOccurred) name:UIApplicationSignificantTimeChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadData) name:KalDataSourceChangedNotification object:nil];
}
return self;
}
比我刚才拖动一个的UIViewController到storybord阶段,改变了它的类在督察KalViewController,从使用TabBar控制器有线它和它的工作。
我创建了一个样本项目:[email protected]
当然干应该记住:
-(void) _configureWithDate:(NSDate *)date
{
logic = [[KalLogic alloc] initForDate:date];
self.initialDate = date;
self.selectedDate = date;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(significantTimeChangeOccurred) name:UIApplicationSignificantTimeChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadData) name:KalDataSourceChangedNotification object:nil];
}
//called if created by nib/storyboard
-(id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder])) {
[self _configureWithDate:[NSDate date]];
}
return self;
}
//the designated initializer for non-nib/storyboard creation
- (id)initWithSelectedDate:(NSDate *)date
{
if ((self = [super init])) {
[self _configureWithDate:date];
}
return self;
}
我创建了分公司,在卡尔来解决这一问题,并张贴一个pull-request。
所以我应该从我自己的viewController类中的KalViewController复制所有代码? – Steaphann
好吧,这不会是最好的解决方案。但是你有什么建议呢? – Steaphann
大声笑我知道的基本知识,我的问题是,我有一个导航控制器内的tabbar。我正在与故事板 – Steaphann