1

我有一个具有以下实现的表格视图,

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    return [self.postsArr count];
}

在我设置标题视图标题之前,这工作正常。我将标题视图标题设置为,

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


    if (self.newsSegmentControl.selectedSegmentIndex == 1) {

        NSLog(@"section:%ld",(long)section-1);
        BTPost *sectionPost = [self.postsArr objectAtIndex:section];

        NSString *actDate = [NSString stringWithFormat:@"/Date(%ld)/",sectionPost.timeStamp];

        NSString *nDate = [[[[actDate componentsSeparatedByString:@"("] objectAtIndex:1] componentsSeparatedByString:@")"] objectAtIndex:0];
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:([nDate doubleValue] / 1000)];
        NSString *dayString = [self getDayLabel:date];
        sectionName =  dayString;

    }else{
        return nil;
    }
    return sectionName;
}

当我运行这个时,

[![http://i.stack.imgur.com/aesU3.png][1]][1]

我得到了这种输出。当我向下滚动时,它会正确显示部分标题。但是当我向上滚动时,它会显示标题为空的标题。我该如何解决这个问题?

4

0 回答 0