指定tableView的数据源
tableView.dataSource = self;

指定tableview代理
tableView.delegate = self;

配置索引值的颜色
tableView.sectionIndexColor = [UIColor lightGreenColor];


设置tableview的headerView(最上面显示的视图)
UILabel * phoneLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
phoneLabel.textColor = [UIColor lightGreenColor];
phoneLabel.text = @"888888";
phoneLabel.textAlignment = NSTextAlignmentCenter;
tableView.tableHeaderView = phoneLabel;
RELEASE_SAFE(phoneLabel);

设置分割线的样式
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;

设置分割线颜色
tableView.separatorColor = [UIColor purpleColor];


self.navigationItem.title = @"lanou";


设置 tableView行高
tableView.rowHeight = 70;


获取文件路径
NSString * path = [[NSBundle mainBundle] pathForResource:@"Student" ofType:@"plist"]


根据文件路径初始化一个OC中字典对象
NSDictionary * dic = [NSDictionary dictionaryWithContentsOfFile:path];


设置行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
偶数的cell 高度为100 ,奇数的cell为50
if (indexPath.row %2 ) {
return 100;
}
return 50;
}



设置tableview右边的索引值(用来快速定位分区,方便查找), 要喝每个分区的title 对应上
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return self.titles;
}

设置分区尾显示的文字
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return nil;
}

设置每个分区头显示的文字
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return self.titles[section];
}

返回tableView的分区个数 --- 1
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.names count];
}

设置tableview 的行数 (每个分组的行数) ------ 2
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
先获取key key = self.titles[section]
key获取对应数组 NSArray * value = self.names[key]
求数组个数 [value count]
NSLog(@"3 %ld",(long)section);
return 1000; //[self.names[self.titles[section]] count];
}


用来创建cell 每一行都要对应一个cell ----- 3
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

UITableViewCellStyleDefault, 只有textLabel
UITableViewCellStyleValue1, textLabel 在左 detailLabel 在右
UITableViewCellStyleValue2, textLabel 在右 detailLabel 在左
UITableViewCellStyleSubtitle textLabel 在上 detailLabel 在下



UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text = self.names[indexPath.row]; //不分组

分组
获取key
获取value
取出元素

cell.textLabel.text = self.names[self.titles[indexPath.section]][indexPath.row];

cell.textLabel.text = self.names[indexPath.section][indexPath.row];
return [cell autorelease]; ////////////////////////

cell.textLabel.text = [NSString stringWithFormat:@"%d",indexPath.row];
return cell;