1

我在表视图中显示了以下数据

// declaration of Array
 NSMutableArray *listOfItems;

//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];

// Adding Item to array
[listOfItems addObject:[object description]];

// Populating tableView with Array
NSString *cellValue = [listOfItems objectAtIndex:[indexPath row]]; 

这表明 :

  • 2012-08-10 07:52:39 +0000

    2012-08-10 07:56:46 +0000

    2012-08-10 07:57:01 +0000

    2012-08-13 02:14:02 +0000

    2012-08-13 02:20:29 +0000

    2012-08-10 07:56:46 +0000

    2012-08-14 08:44:33 +0000

现在我需要有一个分段表视图,以便最终结果应该是这样的

  • 标题

    • 2012-08-10

    价值观

    • 2012-08-10 07:52:39 +0000
    • 2012-08-10 07:56:46 +0000
    • 2012-08-10 07:57:01 +0000
    • 2012-08-10 07:56:46 +0000
  • 标题

    • 2012-08-13

    价值观

    • 2012-08-13 02:14:02 +0000
    • 2012-08-13 02:20:29 +0000

    • 标题 2012-08-14

    价值观

    • 2012-08-14 08:44:33 +0000

即每天的标题和每个部分中每天的不同值我该怎么做?

4

1 回答 1

0
NSMutableArray *array=[[NSMutableArray alloc]init];
[array addObject:[NSArray alloc]initWithObjets:@"2012-08-10 07:52:39 +0000",@"2012-08-10    07:56:46 +0000",@"2012-08-10 07:57:01 +0000",nil]];
[array addObject:[NSArray alloc]initWithObjets:@"2012-08-13 02:14:02 +0000",@"2012-08-13 02:20:29 +0000",nil]];
[array addObject:[NSArray alloc]initWithObjets:@"2012-08-14 08:44:33 +0000",nil]];
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return array.count;
}
-(NSInteger)tableView:(UITableView *)tableViewl numberOfRowsInSection:(NSInteger)section
{
    NSArray *tempArray=[array objectAtIndex:section];
    return tempArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableViewl cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *tempArray=[array objectAtIndex:indexPath.session]
    cell.textLabel.text=[tempArray objectAtIndex:indexPath.row];
    return cell;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    NSArray *tempArray=[array objectAtIndex:section];
    return [tempArray objectAtIndex:0];
}
于 2012-08-17T12:06:22.600 回答