Iphone 标题ForHeaderSection未正确更新节标题信息

Iphone 标题ForHeaderSection未正确更新节标题信息,iphone,uitableview,core-data,Iphone,Uitableview,Core Data,我有两个表视图,其中一个导航到下一个。两者都或多或少使用相同的代码,并使用managedObjectContext和FetchedResultsController设计模式为两个表提供相关数据 当我从第一个tableview导航到第二个tableview时,当数据源只有一个节头/行显示在tableview中时,就会出现问题。我发现数据源没有更新节头信息。但是,如果有多个行或节数据传递到第二个tableview,它将更新此信息 只有在第二次尝试从第一个tableview的不同行导航相同的数据条件时

我有两个表视图,其中一个导航到下一个。两者都或多或少使用相同的代码,并使用managedObjectContext和FetchedResultsController设计模式为两个表提供相关数据

当我从第一个tableview导航到第二个tableview时,当数据源只有一个节头/行显示在tableview中时,就会出现问题。我发现数据源没有更新节头信息。但是,如果有多个行或节数据传递到第二个tableview,它将更新此信息

只有在第二次尝试从第一个tableview的不同行导航相同的数据条件时,此问题才真正值得注意。不知何故,它没有发布第一次尝试时的信息,而是将此信息用作占位符。我可以确认内存管理方法已经完成,并且节标题下的对应行使用了正确的数据,因此正确传递了managedObjectModel

还有其他人遇到过这个问题吗

更新

这是第一个tableview中使用的代码

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 

id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];

if ([fetchSectioningControl selectedSegmentIndex] == 2) {       
    return [NSString stringWithFormat:NSLocalizedString(@"%@ - %d events", @"%@ - %d events"), [sectionInfo name], [sectionInfo numberOfObjects]];

} else if ([fetchSectioningControl selectedSegmentIndex] == 1) {
    return [NSString stringWithFormat:NSLocalizedString(@"%@ - %d events", @"%@ - %d events"), [sectionInfo name], [sectionInfo numberOfObjects]];

} else {
    NSString *dates = [self.dateFormatter stringFromDate:date];
    NSString *compareDate = [sectionInfo name];

    if ([dates isEqualToString:compareDate]) {
        return [NSString stringWithFormat:@"Today"];

    }else {
        return [sectionInfo name];
    }
}
}
-(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section{
id sectionInfo=[[fetchedResultsController节]对象索引:节];
如果([FetchSectionControl selectedSegmentIndex]==2){
返回[NSString stringWithFormat:NSLocalizedString(@“%@-%d个事件”,“@“%@-%d个事件”),[sectionInfo名称],[sectionInfo numberOfObjects];
}else if([FetchSectionControl selectedSegmentIndex]==1){
返回[NSString stringWithFormat:NSLocalizedString(@“%@-%d个事件”,“@“%@-%d个事件”),[sectionInfo名称],[sectionInfo numberOfObjects];
}否则{
NSString*dates=[self.dateFormatter stringFromDate:date];
NSString*compareDate=[sectionInfo name];
if([dates isEqualToString:compareDate]){
返回[NSString stringWithFormat:@“今天”];
}否则{
返回[sectionInfo name];
}
}
}
这是第二个tableview中使用的代码

- (NSString *)tableView:(UITableView *)table titleForHeaderInSection:(NSInteger)section { 

id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
NSString *dates = [self.dateFormatter stringFromDate:date];
NSString *compareDate = [sectionInfo name];
if ([dates isEqualToString:compareDate]) {
    return [NSString stringWithFormat:@"Today"];
}else {
    return [sectionInfo name];
}
}
-(NSString*)tableView:(UITableView*)table titleForHeaderInSection:(NSInteger)section{
id sectionInfo=[[fetchedResultsController节]对象索引:节];
NSString*dates=[self.dateFormatter stringFromDate:date];
NSString*compareDate=[sectionInfo name];
if([dates isEqualToString:compareDate]){
返回[NSString stringWithFormat:@“今天”];
}否则{
返回[sectionInfo name];
}
}

我解决了这个问题,在我的FetchedResultsController的initWithFetchedRequest方法中为cacheName提供了一个nil值。另一个建议是在使用以下方法实例化NSFetchedResultsController之前删除缓存:

+ (void)deleteCacheWithName:(NSString *)name; 

对于发布的答案,此答案的所有分数必须为“不可原谅”

如果您包含一些代码,那么确定问题就会容易得多。能否在TableViewDataSources中为
tableView:titleForHeaderInSection:
方法添加代码?如果两个表的数据源之间的方法完全不同,则包括这两种实现。