ios中tableview侧栏的折叠
#import "ViewController.h"
#define Ksmall 40.0f
#define Klarge 80.0f
#define KNoOpen @"NoOpen" @interface ViewController (){
int flag;
}
@property(nonatomic,retain)NSMutableDictionary *mydata; @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
self.mydata=[NSMutableDictionary dictionary];
UITableView *tableview=[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
tableview.delegate=self;
tableview.dataSource=self;
[self.view addSubview:tableview];
[tableview release];
// Do any additional setup after loading the view, typically from a nib.
} //section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return ;
} //row
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return ;
} -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSLog(@"section--》%zi----row--->%zi",indexPath.section,indexPath.row);
static NSString *cellindentify=@"mycell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellindentify];
if(cell==nil){
cell=[[[UITableViewCell alloc] init] autorelease];
}
cell.textLabel.text=@"bb";
return cell;
} #pragma mark -自定义分组的头部
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return ;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
NSLog(@"viewForHeaderInSection");
UIView *view=[[[UIView alloc] initWithFrame:CGRectMake(, , self.view.bounds.size.width, )] autorelease];
UILabel *lb=[[UILabel alloc] initWithFrame:CGRectMake(, , -, )];
lb.text=@"time"; lb.textAlignment=NSTextAlignmentLeft;
[view addSubview:lb]; UILabel *lb1=[[UILabel alloc] initWithFrame:CGRectMake(, , self.view.bounds.size.width--, view.bounds.size.height)];
lb1.textAlignment=NSTextAlignmentRight;
lb1.text=@"right";
[view addSubview:lb1];
return view;
} #pragma mark -设置CELL的高度
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==){
UITableViewCell *targetCell=[tableView cellForRowAtIndexPath:indexPath];
if(targetCell.frame.size.height==Ksmall+){//折叠的情况
[self.mydata setObject:KNoOpen forKey:indexPath];
}
else{
[self.mydata removeObjectForKey:indexPath];
}
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
} -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.row==){
NSString *isOpen= [self.mydata objectForKey:indexPath];
if ([isOpen isEqualToString:KNoOpen]) {
return Klarge;
}
return Ksmall;
}
else
return Klarge;
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
ios中tableview侧栏的折叠的更多相关文章
- 【转】iOS中设置导航栏标题的字体颜色和大小
原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参 ...
- iOS中设置导航栏标题的字体颜色和大小
iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的 ...
- iOS中TableView小技巧
摘要: TableView是ios开发中经经常使用到的控件,这里统一记录一下开发中遇到的经常使用小技巧,不断探索更新.也希望大家能够告诉我很多其它经常使用的小技巧啦~一起进步 1.去除多余的列表线条 ...
- IOS中TableView的用法
一.UITableView 1.数据展示的条件 1> UITableView的所有数据都是由数据源(dataSource)提供的,所以要想在UITableView展示数据,必须设置UITable ...
- ios中tableview的移动添加删除
// // MJViewController.m // UITableView-编辑模式 // // Created by mj on 13-4-11. // Copyright (c) 2013年 ...
- ios中tableview网封装(viewcontroller封装)常用的
下载地址 http://pan.baidu.com/share/link?shareid=3657500168&uk=923776187 使用框架 1:asIHttpRequest库 2;SB ...
- IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态
一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...
- IOS中TableView的使用(1) -创建一个简单的tableView
创建一个简单的tableView: #import <UIKit/UIKit.h> /*tableView 一定要遵守这两个协议: UITableViewDataSource,UITabl ...
- iOS中tableView组头部或尾部标题的设置
解决在tableView返回组标题直接返回字符串,带来的不便设置组标题样式的问题解决办法,设置尾部标题和此类似 // 返回组头部view的高度 - (CGFloat)tableView:(UITab ...
随机推荐
- HttpWebRequest 对象池 HTTP协议 HttpWebRequest和 Socket的一点总结
相信接触过网络开发的人对HTTP.HttpWebRequest.Socket这些东西都不陌生吧.它们之间的一些介绍和关系我这里都忽略了.开我们平时开发过程中也是很少有机会接触大什么大并发这个东东,一般 ...
- Backbone.js 的 View 中定义事件
使用 Backbone 的 View 时,可以象传统 jQuery 那样定义事件,$("selector").click(function(){...}).幸运的是 Backbon ...
- pThreads线程(三) 线程同步--条件变量
条件变量(Condition Variables) 参考资料:http://game-lab.org/posts/posix-thread-cn/#5.1 条件变量是什么? 条件变量为我们提供了另一种 ...
- python3 杀死进程
在windows10杀死进程:Shadowsocks.exe os.system('taskkill /f /im %s' % 'Shadowsocks.exe')
- Java 读取 .properties 配置文件
java 开发中,经常要读取 properties 配置文件,下面介绍几种读取方式: 1.基于 InputStream 读取配置文件 该方式的优点在于可以读取任意路径下的配置文件 Properties ...
- python3 AttributeError: module 'sklearn' has no attribute 'linear_model'
以下导入方式报错 import sklearn lr = sklearn.linear_model.LinearRegression() # 需要导入sklearn的linear_model 修改导入 ...
- protobuf-c的学习总结
1.前言 项目中用到protobuf-c进行数据序列化,好处在于后期程序扩展性非常好,只需要改动proto的定义就可以保持兼容,非常的灵活方便.关于protobuf-c的详细介绍可以参考google官 ...
- angularJs中$controller的使用
$controller的使用 参考:https://stackoverflow.com/questions/27866620/can-someone-provide-a-use-case-for-th ...
- 利用NATAPP隧道解决微信公众号开发之本地调试难题
一.问题 众所周知,微信公众号开发需要公网的有效域名和80端口,本机当然互联网是访问不了的.那么我们难道去一个公网的服务器去开发吗?那样是不是太土了. 答案当然是,NO 当然我们在做微信支付的时候,有 ...
- RocketMQ【未完成】
RocketMQ 是一款快速地.可靠地.分布式.容易使用的消息中间件,由 alibaba 开发,其前身是 metaq,metaq 的第一个版本是可以看成是linkedin的kafka(scala)的j ...