刷新tableView单行 实现折叠效果
2013-10-21 09:33
453 查看
#define originalHeight 25.0f
#define newHeight 85.0f
#define isOpen @"85.0f"
1、创建好tableView
2、
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath函数中设定的显示为展开后的显示
3、设置点击后的效果,行高变换
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==
0) {
UITableViewCell *targetCell = [tableView
cellForRowAtIndexPath:indexPath];
if (targetCell.frame.size.height ==
originalHeight+1){
[dicClicked setObject:isOpen
forKey:indexPath];
}
else{
[dicClicked removeObjectForKey:indexPath];
}
[self.tableView
reloadRowsAtIndexPaths:[NSArray
arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];//刷新这一行
}
NSLog(@"indexPath=%@",indexPath);
NSLog(@"dicClicked=%@",dicClicked);
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==
0) {
if ([[dicClicked
objectForKey:indexPath] isEqualToString:
isOpen])
return [[dicClicked
objectForKey:indexPath] floatValue];
else
return originalHeight;
}
else {
return 45.0f;
}
}
#define newHeight 85.0f
#define isOpen @"85.0f"
1、创建好tableView
2、
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath函数中设定的显示为展开后的显示
3、设置点击后的效果,行高变换
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==
0) {
UITableViewCell *targetCell = [tableView
cellForRowAtIndexPath:indexPath];
if (targetCell.frame.size.height ==
originalHeight+1){
[dicClicked setObject:isOpen
forKey:indexPath];
}
else{
[dicClicked removeObjectForKey:indexPath];
}
[self.tableView
reloadRowsAtIndexPaths:[NSArray
arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];//刷新这一行
}
NSLog(@"indexPath=%@",indexPath);
NSLog(@"dicClicked=%@",dicClicked);
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row ==
0) {
if ([[dicClicked
objectForKey:indexPath] isEqualToString:
isOpen])
return [[dicClicked
objectForKey:indexPath] floatValue];
else
return originalHeight;
}
else {
return 45.0f;
}
}
相关文章推荐
- ios之TableView实现上下拉动刷新效果
- ios tableView那些事 (十八) UITableView单行刷新数据
- 简易实现 TextView单行文本水平触摸滑动效果
- tableView中实现headView图片拉伸效果的三种解决方案
- 简易实现 TextView单行文本水平触摸滑动效果
- iOS 类似美团外卖 app 两个 tableView 联动效果实现
- iOS 类似美团外卖 app 两个 tableView 联动效果实现
- swift-tableView 代理方法实现点击按钮删除效果
- iOS 类似美团外卖 app 两个 tableView 联动效果实现
- 8-20学习练习[用两个tableview实现类似省市联动选择效果]
- iOS tableView实现顶部图片拉伸效果
- 广告条效果实现----ViewPager加载大图片(LruCache)以及定时刷新
- iOS 类似美团外卖app两个tableView联动效果实现
- FJPullTableView 上拉加载更多的效果实现
- iOS开发中TableView类似QQ分组的折叠与展开效果
- 翻翻git之---利用RecyclerView实现折叠效果 SectionedExpandableGridRecyclerView
- 8-20学习练习[用两个tableview实现类似省市联动选择效果]
- tableView 实现隐藏效果
- iOS tableView实现下拉图片放大效果
- tableView 刷新单行