上节我们讲到如何展示好友信息
http://blog.csdn.net/lwjok2007/article/details/46549111
接下来我们将分组点击的时候折叠起来。
首先新建一个可变字典用来存储当前列表是否展示
NSMutableArray *selectedArr;//控制列表是否被打开
selectedArr=[[NSMutableArray alloc]init];
根据前两节所讲,我们讲分组名称放在section的header上了,但是Header 不像cell一样有点击方法
此时我们可以考虑给header上添加一个button来实现点击的时候打开列表和关闭列表
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
view.backgroundColor=[UIColor whiteColor];
UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(30, 5, SCREEN_WIDTH, 30)];
titleLabel.text=[titleArray objectAtIndex:section];
[view addSubview:titleLabel];
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 20)];
imageView.tag=20000+section;
imageView.image=[UIImage imageNamed:@"arrow_down.png"];
[view addSubview:imageView];
//添加一个button 用来监听点击分组,实现分组的展开关闭。
UIButton *btn=[UIButton buttonWithType: