1.cell for row
<span style="white-space:pre"><span style="background-color: rgb(255, 255, 255);"> </span></span><span style="background-color: rgb(255, 255, 255);">//配置cell</span>
<span style="white-space: pre;"> </span><span style="background-color: rgb(255, 255, 255);">[cell congigCell:cell.dic];</span>
<span style="background-color: rgb(255, 255, 255);"><span style="white-space:pre"> </span>//下拉展开按钮
cell.ZhankaiBtn.tag = indexPath.row+1000;
[cell.ZhankaiBtn addTarget:self action:@selector(zhankai:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;</span>
<span style="background-color: rgb(255, 255, 255);">2.按钮点击事件</span>
<span style="font-size:10px;background-color: rgb(255, 255, 255);"></span><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;">-(void)zhankai:(UIButton *)btn{</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> <span style="white-space:pre"> </span>NSMutableDictionary *dic;</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> <span style="white-space:pre"> </span>btn.selected = !btn.selected;</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> <span style="white-space:pre"> </span>dic = [NSMutableDictionary dictionaryWithDictionary:self.valueArray[btn.tag-1000]];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;">//1 2 标识一种状态 1代表展开状态 2代表闭合状态</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> if ([[dic safeNullWithKey:@"iszhankai"] isEqualToString:@"2"]) {</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo; min-height: 21px;"> [dic setObject:@"1" forKey:@"iszhankai"];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> }else if ([[dic safeNullWithKey:@"iszhankai"] isEqualToString:@"1"]) {</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> [dic setObject:@"2" forKey:@"iszhankai"];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> }else{</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> [dic setObject:@"1" forKey:@"iszhankai"];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> }</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> [self.valueArray replaceObjectAtIndex:btn.tag-1000 withObject:dic];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo;"> <span style="white-space:pre"> </span>NSIndexPath *path = [NSIndexPath indexPathForRow:btn.tag-1000 inSection:1];</p><p style="margin-top: 0px; margin-bottom: 0px; line-height: normal; font-family: Menlo; min-height: 21px;"> <span style="white-space:pre"> </span>[self.ev_tableView reloadRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationAutomatic];</p>
2.height for row
//这里我用一个方法统一来计算高度
return [calcuH cellHeight:dic];
//-----------------------------------------------
-(CGFloat)cellHeight:(NSDictionary *)dic{
//45 26+
CGFloat heightt = 45+26+5;
/*评价内容*/ //在我的另一篇文章里有这个方法,地址:http://blog.csdn.net/jp940110jpjp/article/details/42262021
CGSize labContextWidth = [calculatorStringSize stringSize:[dic objectForKey:@"evaluateContext"] widthOfFatherView:WIDTH-20 textFont:[UIFont systemFontOfSize:11.0]];
if ([[dic safeNullWithKey:@"iszhankai"] isEqualToString:@"1"]) {
heightt+= labContextWidth.height;
}else{
if (labContextWidth.height>=30) {
heightt+= 30+10+14;
}else{
heightt+= labContextWidth.height;
}
}
CGFloat imgVWidth = (SCREEN_WIDTH-26-18) /4.0;
NSArray *imageArray = dic[@"evaluateIcons"];
if (imageArray.count>=1) {
heightt+= 10+imgVWidth+15+12+20;
}else{
heightt+= 10+15+12+20;
}
return heightt;
}