.m 中 開始走起ide
NSIndexPath *selectIndex;//標記cell用3d
- (void)viewDidLoad{blog
selectIndex = nil;it
}io
//cell高度改變table
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{select
//選中以後的cell的高度scroll
if (indexPath.row == selectIndex.row && selectIndex != nil){queue
return 200;im
}
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];
}
這樣就能夠實現效果了 裏面東西本身弄