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 ...
随机推荐
- SharePoint 列表权限控制
一提到sharepoint 我相信权限控制一定会是一个很重要的话题,尤其是对列表的权限控制,创建.修改.查看权限.其实网上这方面的资料已经很多了,尤其是以下2篇文章,后来索性把CodeArt_Perm ...
- Server 2008 R2大改造变成梦幻Win7系统
在此之前先补充一下知识Windows Server 2008和Windows Server 2008 R2的不同之处Windows Server 2008是基准与Vista的内核构建的,支持X86框架 ...
- [leetcode]Reverse Words in a String @ Python
原题地址:https://oj.leetcode.com/problems/reverse-words-in-a-string/ 题意: Given an input string, reverse ...
- ARDC Android 远程桌面助手 录屏 演示 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- memcached安装和验证
1> libevent安装 官网down: http://www.monkey.org 我的网盘down:http://pan.baidu.com/s/1qW8syZi [root@luozh ...
- Android -- 屏幕亮度
获取屏幕亮度 int getScreenBrightness(Activity activity) { int value = 0; ContentResolver cr = activity.get ...
- Building LinkedIn’s Real-time Activity Data Pipeline
转自:http://blog.163.com/guaiguai_family/blog/static/20078414520138911393767/ http://sites.computer.or ...
- [Angular] Communicate with Angular Elements using Inputs and Events
In a real world scenario we obviously need to be able to communicate with an Angular Element embedde ...
- javascript获取时间差
function GetDateDiff(startTime, endTime, diffType) { //将xxxx-xx-xx的时间格式,转换为 xxxx/xx/xx的格式 startTime ...
- Tomcat的性能与最大并发配置
当一个进程有 500 个线程在跑的话,那性能已经是很低很低了.Tomcat 默认配置的最大请求数是 150,也就是说同时支持 150 个并发,当然了,也可以将其改大. 当某个应用拥有 250 个以上并 ...