2010-12-06 39 views
0

相關代碼在這裏:的UITableView不顯示部分altough創建它們

-(UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*) indexPath 
{ 
UITableViewCell *cell; 
NSInteger currentRow = 0; 
for (int i = 0; i < [indexPath section]; i++) { 
    currentRow += ((sectionNumber*) [numSections objectAtIndex:i]).num; 
} 
currentRow += [indexPath row]; 
NSLog(@"[current row] %d", currentRow); 
//if (lineFound == YES){ 
    cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"%d", currentRow]]; 
    if (cell == nil){ 
    [[NSBundle mainBundle] loadNibNamed:@"pathResultsCell" owner:self options:nil]; 
    cell = pathCell; 
    self.pathCell = nil; 
    PathTimesRow *myRow = [resultArray objectAtIndex:currentRow]; 

    NSString * img = [myRow.LineOperatingCompanyID stringByAppendingString:@".gif"]; 
    companyImg.image = [UIImage imageNamed:img]; 
    line.text=myRow.LineName; 
    source.text= myRow.StartPlaceFullName; 
    dest.text=myRow.EndPlaceFullName; 
    if (myRow.DepDateTime != myRow.FirstPlaceDepDateTime) 
    TimeS.text = @"*"; 
    TimeS.text=[TimeS.text stringByAppendingString:[[myRow.DepDateTime substringFromIndex:11] substringToIndex:5]]; 
    TimeD.text=[[myRow.ArrDateTime substringFromIndex:11] substringToIndex:5]; 
    tmpDate=[[NSString alloc]initWithString:[myRow.DepDateTime substringToIndex:10]]; 
    NSLog(@"[PathSearchResult]date: %@", myRow.DepDateTime); 

    } 
// } 

return cell; 

} 

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
return tmpDate; 
} 



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
NSLog(@"sections %d", countSections); 
if (countSections > 1) { 
    NSLog(@"this is the number of sections", countSections); 
    return countSections; 
} 
return 1; 

} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
if (countSections>1) { 
    NSLog(@"section %d", section); 
    sectionNumber * tmp= [numSections objectAtIndex:section]; 
    NSLog(@"rows %d", tmp.num); 
    return tmp.num; 
} 


return [resultArray count]; 
} 

的的NSLog的指示以下精彩條件:

2010-12-06 14:55:13.531 iBusILp[9467:207] sections 7 
2010-12-06 14:55:13.533 iBusILp[9467:207] this is the number of sections 
2010-12-06 14:55:13.534 iBusILp[9467:207] section 6 
2010-12-06 14:55:13.534 iBusILp[9467:207] rows 1 
2010-12-06 14:55:13.534 iBusILp[9467:207] section 0 
2010-12-06 14:55:13.535 iBusILp[9467:207] rows 1 
2010-12-06 14:55:13.539 iBusILp[9467:207] section 1 
2010-12-06 14:55:13.540 iBusILp[9467:207] rows 1 
2010-12-06 14:55:13.540 iBusILp[9467:207] section 2 
2010-12-06 14:55:13.541 iBusILp[9467:207] rows 1 
2010-12-06 14:55:13.542 iBusILp[9467:207] section 3 
2010-12-06 14:55:13.542 iBusILp[9467:207] rows 2 
2010-12-06 14:55:13.544 iBusILp[9467:207] section 4 
2010-12-06 14:55:13.545 iBusILp[9467:207] rows 1 
2010-12-06 14:55:13.545 iBusILp[9467:207] section 5 
2010-12-06 14:55:13.545 iBusILp[9467:207] rows 3 
2010-12-06 14:55:13.546 iBusILp[9467:207] [current row] 0 
2010-12-06 14:55:13.550 iBusILp[9467:207] [PathSearchResult]date: 2010-12-06T19:00:00+02:00 
2010-12-06 14:55:13.550 iBusILp[9467:207] [current row] 1 
2010-12-06 14:55:13.552 iBusILp[9467:207] [PathSearchResult]date: 2010-12-07T19:00:00+02:00 
2010-12-06 14:55:13.553 iBusILp[9467:207] [current row] 2 
2010-12-06 14:55:13.556 iBusILp[9467:207] [PathSearchResult]date: 2010-12-08T19:00:00+02:00 
2010-12-06 14:55:13.556 iBusILp[9467:207] [current row] 3 
2010-12-06 14:55:13.558 iBusILp[9467:207] [PathSearchResult]date: 2010-12-09T19:00:00+02:00 
2010-12-06 14:55:13.559 iBusILp[9467:207] [current row] 4 
2010-12-06 14:55:13.561 iBusILp[9467:207] [PathSearchResult]date: 2010-12-09T20:00:00+02:00 
2010-12-06 14:55:14.863 iBusILp[9467:207] [current row] 5 
2010-12-06 14:55:14.865 iBusILp[9467:207] [PathSearchResult]date: 2010-12-10T15:00:00+02:00 
2010-12-06 14:55:14.879 iBusILp[9467:207] [current row] 6 
2010-12-06 14:55:14.882 iBusILp[9467:207] [PathSearchResult]date: 2010-12-11T19:00:00+02:00 
2010-12-06 14:55:14.896 iBusILp[9467:207] [current row] 7 
2010-12-06 14:55:14.898 iBusILp[9467:207] [PathSearchResult]date: 2010-12-11T20:00:00+02:00 
2010-12-06 14:55:14.944 iBusILp[9467:207] [current row] 8 
2010-12-06 14:55:14.947 iBusILp[9467:207] [PathSearchResult]date: 2010-12-11T21:30:00+02:00 
2010-12-06 14:55:14.961 iBusILp[9467:207] [current row] 9 
2010-12-06 14:55:14.964 iBusILp[9467:207] [PathSearchResult]date: 2010-12-12T19:00:00+02:00 
2010-12-06 14:55:15.161 iBusILp[9467:207] [current row] 6 
2010-12-06 14:55:15.164 iBusILp[9467:207] [PathSearchResult]date: 2010-12-11T19:00:00+02:00 
2010-12-06 14:55:15.429 iBusILp[9467:207] [current row] 5 
2010-12-06 14:55:15.432 iBusILp[9467:207] [PathSearchResult]date: 2010-12-10T15:00:00+02:00 

對不起,超詳細的問題。出了什麼問題?

回答

0

您的代碼看起來正確。但是當tmpDate設置爲- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return tmpDate; } 時真的設置了嗎?

您是否嘗試過使用字符串?

+0

你是對的。謝謝。 – 2010-12-06 13:44:35

相關問題