2012-08-14 55 views
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 7时52分39秒+0000

    2012-08-10 7时56分46秒+0000

    2012-08-10 7时57分01秒+0000

    2012年8月13日2时14分02秒+0000

    2012年8月13日2时20分29秒+0000

    2012-08-10 7点56分46秒+0000

    2012-08-14 8时44分33秒+0000

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

  • 部首

    • 2012-08-10

    • 2012-08-10 7点52分39秒0000
    • 2012-08-10 7点56分:46 +0000
    • 2012-08-10 07:57:01 +0000
    • 2012-08-10 07:56:46 +0000
  • 部首

    • 2012年8月13日

    • 2012年8月13日2点14分02秒0000
    • 2012-08 -13 02:20:29 +0000

    • 部首2012-08-14

    • 2012-08-14 8时44分33秒0000

即头的每一天和不同每个部分每天的价值 我该怎么做?

+0

就像一个帮助,没有代码: 我建议你只为你的项目列表创建2个数组。创建一个处理将这些项分离到这些数组中的方法。它应该创建一个包含您的标题日期的数组,并在另一个数组(2D)中为数组添加值。 然后,您将按照正确的顺序填写日期以填充表格。我不知道你想如何显示你的标题数据和你的值之间的差异?也许你可以为每个单元格添加一些空格,这些空格将包含你的值以创建“崩溃”效果。 – NDY 2012-08-14 11:11:05

回答

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]; 
}