类似qq分组栏-动态分组
.h
(void)viewDidLoad {
[super viewDidLoad];
_tableView = [[UITableView alloc] initWithFrame:[UIScreenmainScreen].bounds style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
_array = [[NSMutableArray alloc] initWithObjects:[[NSArray alloc]initWithObjects:@"AA",@"BB",@"CC",@"DD",nil],
[[NSArray alloc]initWithObjects:@"EE",@"FF",@"GG",@"XX",@"ZZ",nil],
[[NSArray alloc]initWithObjects:@"JJ",@"VV",@"EE",@"NN",nil],
nil];
flag = (BOOL*)malloc([_arraycount]*sizeof(BOOL*));
memset(flag, NO, sizeof(flag));
}
.m文件的内容
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return [_array count];
}
-(NSInteger)tableView:(UITableView *)tableViewnumberOfRowsInSection:(NSInteger)section {
return [self numberOfRowsInSection:section];
}
- (UITableViewCell*)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier =@"CellIdentifier";
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle =UITableViewCellSelectionStyleNone;
}
NSString* str = [[_array objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
cell.textLabel.text = str;
return cell;
}
- (UIView*)tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section
{
UIButton *abtn = [UIButtonbuttonWithType:UIButtonTypeInfoDark];
abtn.frame = CGRectMake(0, 0, 200, 100);
abtn.titleLabel.text = @"HEADER";
abtn.tag = section;
[abtn addTarget:self action:@selector(headerClicked:)forControlEvents:UIControlEventTouchUpInside];
return abtn;
}
//
-(void)headerClicked:(id)sender
{
int sectionIndex = ((UIButton*)sender).tag;
flag[sectionIndex] = !flag[sectionIndex];
[_tableView reloadData];
}
-(int)numberOfRowsInSection:(NSInteger)section
{
if (flag[section]) {
return[(NSArray*)[_array objectAtIndex:section] count];
}
else {
return0;
}
}
类似qq分组栏-动态分组相关推荐
- html纯css类似qq登录的动态背景,QQ登录蓝色动态背景JS实现
QQ2019版登录界面的蓝色背景 JS实现代码 $(function () { if (!window.ActiveXObject && !!document.createElemen ...
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(二)
第一篇链接: android RecyclerView一步步打造分组效果.类似QQ分组.折叠菜单.分组效果(一) 注!已更新代码! 上一篇写了分组效果的初步实现: 这一篇就继续增加分组折叠效果和基类的 ...
- Qt可拖拽排序表格(类似QQ好友分组排序)
1,简介 为了最佳体验,一个拖拽行排序的功能研究了几个小时.效果参考的QQ好友分组的排序. 网上查了下好像没有人发布QT版类似的代码,于是自己动手 QQ好友分组排序效果: 2,效果 这是最终效果图,有 ...
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(一)
第二篇文章链接: android RecyclerView一步步打造分组效果.类似QQ分组.折叠菜单.分组效果(二) 效果图: 前言 之前看到这种效果如果用recyclerview来实现没有一点思路, ...
- Android 自定义RecycleView实现多级树(类似qq分组列表)
由于工作需要开发一个类似qq分组列表功能,所以就自定义RecycleView来实现功能 效果图: 自定义View: import java.util.ArrayList; import java.ut ...
- Qt可拖拽排序表格(解决滚动条不兼容问题,类似QQ好友分组排序)
原版链接 https://blog.csdn.net/dpsying/article/details/77206127 Qt可拖拽排序表格(类似QQ好友分组排序) 感谢博主无私分享 修改后,解决了滚动 ...
- html仿qq分组,iOS 实现类似QQ分组样式的两种方式
思路 思路很简单,对模型数据操作或则控制界面显示 先看下json部分数据 "chapterDtoList": [{ "token": null, "i ...
- excel学习-数据透视表(自动分组+手动分组+制作动态数据源)
文章目录 自动分组 日期自动分组 数字自动分组 手动分组 数字手动分组 组合结果修改 文本手动分组 制作动态数据源 数据修改,数量不变 数据数量变化 自动分组 日期自动分组 数字自动分组 手动分组 数 ...
- android 网络广播 类似QQ动态检查网络
private ConnectivityManager mConnectivityManager; private NetworkInfo netInfo; 在onCreate 注册广播 I ...
- PHP防QQ列表右划,react native 实现类似QQ的侧滑列表效果
如果列表行数据需要更多的操作,使用侧滑菜单是移动端比较常见的方式,也符合用户的操作习惯,对app的接受度自然会相对提高点.最近得空就把原来的react-native项目升级了侧滑操作,轻轻松松支持an ...
最新文章
- .NET中常见的 IL 指令集
- eclipse rcp应用程序重启
- html修改原生checkbox选中的颜色_[三分钟小文]前端性能优化-HTML、CSS、JS部分
- MPEG-4 AVC/H.264 信息
- 古老的话题:成本控制
- POJ 1002 解题分析
- 都说如果朋友都是有钱人,你也会更容易发财
- java 类型通配符_java中泛型之类型通配符(?)
- 2.看板方法---什么是看板方法
- Qt中connect的几种写法与遍历ComBox的值
- bp神经网络模型拓扑结构,bp神经网络模型结构图
- qa 芯片测试_关于半导体设备测试,看这一篇就够了
- 主板怎么开启csm_B460主板BIOS设置CSM选项无法开启的解决方法
- 无锡旅游景点古文化的调研报告
- 局域网下连接其他电脑的HDFS集群
- git 提交代码防止尾行序列LF转为CRLF
- C1041: 无法打开程序数据库“xxx.pdb”;如果要将多个 CL.EXE 写入同一个 .PDB 文件,请使用 /FS
- Python全栈开发教程笔记
- ajax调用ajax_AJAX即将到来
- c语言int作用,c语言中int的用法