.m 中 开始走起
NSIndexPath *selectIndex;//标记cell用
- (void)viewDidLoad{
selectIndex = nil;
}
//cell高度改变
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//选中之后的cell的高度
if (indexPath.row == selectIndex.row && selectIndex != nil){
return 200;
}
else
return 100;
}
//加载cell里
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//判断cell是否处于选中状态,并且用不同的identifier标记重用;
//选中的cell改变高度,同时在cell的下方添加需要的button;
if (indexPath.row == selectIndex.row && selectIndex != nil) {//选中状态
static NSString *identifier = @"cell1";
***TableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell1) {// 这里就可以添加下菜单里的东西了
cell1 = [[***TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
UIView *blackView = [[UIView alloc]initWithFrame:CGR(0, 100, ScreenWidth, 100)];
blackView.backgroundColor = [UIColor redColor];
[cell1.contentView addSubview:blackView];
}
cell1.selectionStyle = UITableViewCellSelectionStyleNone;
return cell1;
}
else{// 非选中状态
static NSString *identifier = @"cell";
***TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[***TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.resumeModel = resumeArry[indexPath.row];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
return nil;
}
//点击cell
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (!selectIndex) {
selectIndex = indexPath;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectIndex] withRowAnimation:UITableViewRowAnimationAutomatic];
}
else{
BOOL selectTheSameRow = indexPath.row == selectIndex.row?YES:NO;
//两次点击不同的cell
if (!selectTheSameRow) {
//收起上次点击展开的cell
NSIndexPath *tempIndexPath = [selectIndex copy];
selectIndex = nil;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:tempIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
//展开新选的cell
selectIndex = indexPath;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectIndex] withRowAnimation:UITableViewRowAnimationAutomatic];
}
else{
//相同cell 收起cell
selectIndex = nil;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
[tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:YES];
}
这样就可以实现效果了 里面东西自己弄