类似qq分组栏-动态分组
来源:互联网 发布:p5.js正方形 编辑:程序博客网 时间:2024/04/30 06:33
.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;
}
}
(void)viewDidLoad {
}
.m文件的内容
-(NSInteger)numberOfSectionsInTableV
}
-(NSInteger)tableView:(UITableView *)tableViewnumberOfRowsInSection:(NSInteger)section {
}
- (UITableViewCell*)tableView:(UITableView *)tableViewcellForRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (UIView*)tableView:(UITableView *)tableViewviewForHeaderInSection:(NSInteger)section
{
}
////////////////////////////////////////////////////////////////////////////////////////
//
-(void)headerClicked:(id)sender
{
}
-(int)numberOfRowsInSection:(NSInteger)section
{
}
- 类似qq分组栏-动态分组
- 类似QQ好友分组栏
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(一)
- android RecyclerView一步步打造分组效果、类似QQ分组、折叠菜单、分组效果(二)
- QQ 分组
- QQ分组
- qq分组
- ListView分组,类似联系人分组
- Android开发---类似QQ分组列表的实现案例
- TableView类似QQ分组的折叠与展开
- Android 使用BRVAH 实现二级菜单。类似QQ分组
- iOS Cell上实现简单的分组(类似与QQ分组)
- QQ分组思路
- QQ分组效果
- QQ 分组界面
- QQ分组图案
- android 仿qq分组
- QQ界面含图片动态分组菜单的实现[C#]
- 取消键盘
- Cell选中时自定义背景
- UIImageview使用网上照片
- UIWebView的使用方法
- UIimageView中图片滚动出现
- 类似qq分组栏-动态分组
- tableview的代理
- Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER 解决方案
- 导航器自制导航按钮
- UIAlertView
- 准备工作完成-1月8日
- presentModalView
- UIActinSheet和UIActionSheetDelegate
- UItableView的类型带图-新手直观图