QQ分组思路

一、定义一个全局变量数组 dataArray

二、有数据源字典,字典里面有:1、section的大标题,用@“name”标示,2、有一数组,里面装了row的小标题,整个数组用@“subname”标示

三、把字典放到全局变量数组 dataArray中

四、

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 在这个函数中,加上button

五、在button的点击事件中,操作展开/合上操作,重点是在reloadtableview的时候,根据section所取字典的expand值来,决定row的行数是几行,则game completed,具体的是:在dataArray中,

NSMutableDictionary* d = [dataArrayobjectAtIndex:section];

在字典中加上是否展开这一标示

//对指定的节进行展开/折叠操作

-(void)btnClickCollapseOrExpand:(int)section{

    

    Boolean expanded = NO;

    NSMutableDictionary* d = [dataArrayobjectAtIndex:section];

    

    //若本节model中的“expanded”属性不为空,则取出来

    if([d objectForKey:@"expanded"]!=nil)

        expanded=[[d objectForKey:@"expanded"]intValue];

 

    NSLog(@"expand = %d",expanded);

    //若原来是折叠的则展开,若原来是展开的则折叠

    [d setObject:[NSNumbernumberWithBool:!expanded]forKey:@"expanded"];

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    if (![selfisExpanded:section])

        return 0;

    NSDictionary* d=[dataArrayobjectAtIndex:section];

    return [[dobjectForKey:@"user"]count];

}


//返回指定节的“expanded”

-(Boolean)isExpanded:(int)section{

    Boolean expanded = NO;

    NSMutableDictionary* dic = [dataArrayobjectAtIndex:section];

    //若本节model中的“expanded”属性不为空,则取出来

    if([dic objectForKey:@"expanded"]!=nil)

        expanded=[[dic objectForKey:@"expanded"]intValue];

    return expanded;

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值