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 に答える