iOS开发笔记-cell里点击按钮展开收起-动态改变cell行高
来源:互联网 发布:c语言for语句continue 编辑:程序博客网 时间:2024/06/05 08:15
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;
}
- iOS开发笔记-cell里点击按钮展开收起-动态改变cell行高
- iOS开发笔记- cell里放textView根据输入的文字动态改变textView以及cell高度
- iOS cell的展开与收起
- 点击cell动态改变cell高度
- cell的展开和收起
- iOS 点击cell改变背景颜色或者图片&&cell中其他部分取消高亮显示
- 点击tableview里的cell后改变cell的背景图片
- UITableView点击展开cell
- ios 开发自定义 cell 行高
- ios开发笔记之如何让tableView根据文本内容动态改变cell的高度
- iOS开发-UI控件:动态改变UITableView中的Cell高度
- iOS点击Cell中的按钮时,取所在的Cell
- IOS table动态cell - 笔记
- (iOS开发) 动态cell高度
- IOS 动态改变cell的高度
- IOS 动态改变cell的高度
- iOS 动态改变cell的高度
- IOS应用开发11——UITableView的cell点击展开
- C++打印中文
- ubuntu搭建本地源
- 单元格合并
- Android 混淆代码总结
- Android中自定义View(1)
- iOS开发笔记-cell里点击按钮展开收起-动态改变cell行高
- 【Android 应用开发】 ActionBar 样式详解 -- 样式 主题 简介 Actionbar 的 icon logo 标题 菜单样式...
- SpringMvc下载文件
- tar命令
- C语言开发总结(三)
- Meteor methods call apply 使用
- Kettle学习1
- Freemarker 使用
- RUNTIME_CLASS(运行时间类)