点击UITableviewCell展开收缩
#import "ViewController.h"
#import "ZSDTestCell.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
{ NSMutableArray *dataArray; //数组保存显示内容
NSIndexPath *selectIndex; //记录当前选择的索引
} @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
dataArray=[NSMutableArray array];
for (int i=; i<; i++) {
[dataArray addObject:[NSString stringWithFormat:@"%d",i]];
}
selectIndex=nil;
} -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ return dataArray.count; }
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return ; }
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ if (indexPath==selectIndex)
{
return 88.0;
}
return 44.0f;
} -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *normalImg = [UIImage imageNamed:@"member_icon_more"];
UIImage *selectImg = [UIImage imageNamed:@"common_icon_down"];
ZSDTestCell *testCell=[tableView dequeueReusableCellWithIdentifier:@"ZSDTestCell" forIndexPath:indexPath];
testCell.firstLabel.text=dataArray[indexPath.row];
if (selectIndex==indexPath)
{
testCell.remindImageView.image=selectImg;
testCell.secondLabel.text=[NSString stringWithFormat:@"测试第%@行UITableviewCell收缩效果",dataArray[indexPath.row]];
}
else
{
testCell.remindImageView.image=normalImg;
testCell.secondLabel.text=nil;
}
return testCell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectIndex==nil)
{
selectIndex=indexPath;
}
else
{
bool selectedOtherRow=![selectIndex isEqual:indexPath];
selectIndex=nil;
if(selectedOtherRow)
{
selectIndex=indexPath;
}
}
[tableView reloadData];
} @end

点击UITableviewCell展开收缩的更多相关文章
- 点击UITableView的cell展开收缩
在项目中有个需求,点击表视图的单元格展开,再点击另外一个单元格或者本身又收缩,经过一段时间尝试,实现了该功能,现在记录分享总结下. 首先要理解UITableView代理方法调用的先后顺序. 当 ...
- iOS tableview cell 的展开收缩
iOS tableview cell 的展开收缩 #import "ViewController.h" @interface ViewController ()<UITabl ...
- HTML5每日一练之details展开收缩标签的应用
details标签的出现,为我们带来了更好的用户体验,不必为这种收缩展开的效果再编写JS来实现.注:目前仅Chrome支持此标签. details有一个新增加的子标签——summary,当鼠标点击su ...
- WordPress文章页添加展开/收缩功能
很多时候我们在WordPress上发布一些文章的时候里面都包含了很多的代码,我一般又不喜欢把代码压缩起来而喜欢让代码格式化显示,但是格式化显示通常会让文章内容看起来很多,不便于访问者浏览,所以今天就介 ...
- js之展开收缩菜单,用到window.onload ,onclick,
目标效果:点击标签1,如果列表标签的style的display是block,改成none,否则改成block,来达到展开收缩菜单效果 一.准备阶段 html文件 <!DOCTYPE html&g ...
- 微信小程序 - 展开收缩列表
代码源自于:微信小程序示例官方 index.wxml <block wx:for-items="{{list}}" wx:key="{{item.id}}" ...
- SlickGrid example 5:带子项的展开收缩
带子项的展开收缩. 代码: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Ty ...
- 展开/收缩 ul
了一个展开收缩的东东,留着以后万一用到 后台递归生成的函数(这里是一个反射参数展示,支持多层级展开显示,后台反射如何多层级解析的方法有时间再补上吧) /// <summary> /// 递 ...
- js实现的侧边栏展开收缩效果
原文地址:http://www.softwhy.com/forum.php?mod=viewthread&tid=12246 <!DOCTYPE html> <html> ...
随机推荐
- AutoCAD DxfCode组码值说明
值 说明 -5 APP:永久反应器链 -4 APP:条件运算符(仅与 ssget 一起使用) -3 APP:扩展数据 (XDATA) 标记(固定) -2 APP:图元名参照(固定) -1 APP:图元 ...
- [iOS微博项目 - 2.6] - 获取微博数据
github: https://github.com/hellovoidworld/HVWWeibo A.新浪获取微博API 1.读取微博API 2.“statuses/home_time ...
- Vusual C++连接Mysql和从MySql中取出数据的API介绍
.1 mysql_real_connect() 2.1.1 函数原型: MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const ...
- “IPSec 共享密钥”丢失。
“IPSec 共享密钥”丢失.请验证您的设置并尝试重新连接. 但是这个vpn原来使用时不需要配置 共享的密钥,而且我也没有这个共享的密钥, 搜了下Mac OSX可以修改配置来绕过它. 在/etc/pp ...
- chrome emulator use-agent 设置 chrom模拟手机客户端
谷歌升级以后,发现找不到use-agent设置了 在Element 下点击ESC 出现console,再点击Emulation就出现了
- 在CentOS 5.8上搭建PPTP VPN服务
在天朝上网,vpn已经是必备之物了,我也记录一下搭建vpn服务的方法. 1. 确认内核是否支持MPPE模块MPPE用来支持Microsoft Point to Point Encryption, 包括 ...
- POJ2503——Babelfish
Description You have just moved from Waterloo to a big city. The people here speak an incomprehensib ...
- Junit4单元测试
在Eclipse中使用JUnit4进行单元测试(初级篇) 在Eclipse中使用JUnit4进行单元测试(中级篇) 在Eclipse中使用JUnit4进行单元测试(高级篇)
- 【汉字乱码】IE下GET形式传递汉字。
js:encodeURI(); php:urlencode(); 举例: 本来打算这样使用 <a href="list.php?plate=辖区动态" charset=&qu ...
- 也来说说C#异步委托(转)
原文地址: http://www.cnblogs.com/lxblog/archive/2012/12/11/2813893.html 前些日子,看到园子里面有人用老王喝茶的例子讲解了一下同步和异步, ...