iOS学习笔记之UITableView之右侧索引
来源:互联网 发布:arp攻击 c语言 编辑:程序博客网 时间:2024/05/16 05:41
今天做的小demo是实现类似于咱们iPhone上通讯录中的索引,非常简单,大家可以参考一下,有什么不对的地方还请指出!
索引要实现的方法- (NSArray )sectionIndexTitlesForTableView:(UITableView )tableView
**
plist文件
**
#import "ViewController.h"//标识符#define MARK @"carList"@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>@property (nonatomic, strong)NSArray *listTeams;@end@implementation ViewController//懒人加载数据- (NSArray*)listTeams{ if (_listTeams == nil) { _listTeams = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"cars_total" ofType:@"plist"]]; } return _listTeams;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}#pragma mark --设置组count- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [self listTeams].count;}#pragma mark --设置行count- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSArray *rowArray = [self getDiction:section][@"cars"]; return rowArray.count;}#pragma mark 设置cell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MARK]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MARK]; } NSArray *rowArray = [self getDiction:indexPath.section][@"cars"]; NSDictionary *rowDic = rowArray[indexPath.row]; cell.textLabel.text = rowDic[@"name"]; cell.imageView.image = [UIImage imageNamed:rowDic[@"icon"]]; return cell;}#pragma mark --设置组标题- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ return [self getDiction:section][@"title"];}#pragma mark --数据元协议设置索引 - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{ //设置索引数组 NSMutableArray *sectionIndex = [[NSMutableArray alloc] init]; //从数据中取得索引 for (NSDictionary *str in self.listTeams) { [sectionIndex addObject:str[@"title"]]; } //返回索引 return sectionIndex;}#pragma mark --取出plist中的字典- (NSDictionary *)getDiction:(NSInteger)section{ return self.listTeams[section];}@end
想点击索引放大,但是索引没有frame之类的,只有color,网上也找了下没找到,有大神知道的还请指教下小白
1 0
- iOS学习笔记之UITableView之右侧索引
- 猫猫学IOS(十三)UI之UITableView学习(下)汽车名牌带右侧索引
- AJ学IOS(13)UI之UITableView学习(下)汽车名牌带右侧索引
- (素材源码)猫猫学IOS(十三)UI之UITableView学习(下)汽车名牌带右侧索引
- iOS 之 UITableView 使用索引
- iOS学习笔记之TableViewCell右侧滑动多项操作
- iOS学习笔记之UITableView(1)
- IOS学习之UITableView
- IOS学习之 UITableView
- IOS学习之UITableView
- ios学习之UITableView(一)
- IOS UI学习之UITableView
- iOS开发学习之UITableView
- iOS中UITableView学习笔记(二)之cell重用
- IOS学习笔记(一)之UITableView表视图
- iOS学习笔记之UI-UISearchController-And-UITableView
- ios学习笔记之-UITableView的分组显示
- [ios]iOS学习之UITableView(三):进阶篇索引,标记和自定义的table
- Redis快速入门
- mongodb安装
- lightoj 1191 - Bar Codes 简单DP
- contact
- ARM嵌入式Linux设备树简介及应用示例
- iOS学习笔记之UITableView之右侧索引
- nyoj540(结构体排序)
- WebService之SOAP与REST
- 第1周 《C语言及程序设计》资料3——C语言中转义字符
- MAC下配置ZSH
- mysql 常用命令及语法
- Android develop tricks——整理自国外的一些Blog
- 数据库范式
- 总结的一些面试问题-java