iOS tableView索引
来源:互联网 发布:淘宝回购率 编辑:程序博客网 时间:2024/05/16 09:53
其实tableView的索引的实现非常简单,主要是靠下面这个方法再结合多分区实现的:
//建立浮动索引
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return [NSArray arrayWithObjects:@"S",@"H",@"S", nil];
}
以下的代码中的data是一个字典,indexs是字典的key所组成的数组。用字典中的数组来填充多分区中的数据。
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return [indexscount];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSString *secNum = [indexsobjectAtIndex:section];
return [[dataobjectForKey:secNum] count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellId =@"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell == nil) {
cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellId];
}
NSInteger rowNo = indexPath.row;
NSInteger rowSe = indexPath.section;
cell.textLabel.text = [[dataobjectForKey:[indexsobjectAtIndex:rowSe]] objectAtIndex:rowNo];
return cell;
}
//建立浮动索引
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
return [NSArrayarrayWithObjects:@"S",@"H",@"S",nil];
}
//分区页眉
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [indexsobjectAtIndex:section];
}
//分区页脚
//-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
// NSString *str = [NSString stringWithFormat:@"一共有%lu个人物",(unsigned long)[[data objectForKey:[indexs objectAtIndex:section]] count]];
// return str;
//}
- iOS tableView索引
- iOS tableView分区+索引
- ios tableView那些事 (十三) 给 tableview 添加索引
- ios tableView那些事 (十三) 给 tableview 添加索引
- iOS中tableview更改索引颜色
- 【代码笔记】iOS-带索引的tableView
- iOS UITableView(九) 给tableView添加索引
- iOS tableView 添加索引后 索引遮盖 headview 解决办法
- iOS之TableView分组目录(快速索引)的使用
- iOS中实现tableView的中英文排序索引
- iOS开发 自定义tableView样式(使用代码/使用Interface Builder)、分组显示、给TableView增加索引、给TableView增加SearchBar
- ios tableview
- iOS tableView
- TableView iOS
- ios tableview
- iOS---tableview
- [iOS]TableView
- iOS tableView
- Trie模板
- hdu1011 树形dp
- iOS DEV info 启动画面 icon
- Algorithms—43.Multiply Strings
- 困扰着初级程序员的无数个BUG
- iOS tableView索引
- ionic项目之ngcordova插件之camera
- 超长正整数相加
- CodeForces 469C - 24 Game
- pthread_create线程创建的过程剖析
- 杭电 2032 杨辉三角
- C++11学习笔记(变量和基本类型)
- 【Android】Android布局中实现圆角边框
- 9秒学院Cocos2d-x基础分析学习