#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侧栏的折叠的更多相关文章

  1. 【转】iOS中设置导航栏标题的字体颜色和大小

    原文网址:http://www.360doc.com/content/15/0417/11/20919452_463847404.shtml iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参 ...

  2. iOS中设置导航栏标题的字体颜色和大小

    iOS中设置导航栏标题的字体颜色和大小,有需要的朋友可以参考下. 在平时开发项目的时候,难免会遇到修改导航栏字体大小和颜色的需求,一般使用自定义视图的方法,其实还存在一种方法. 方法一:(自定义视图的 ...

  3. iOS中TableView小技巧

    摘要: TableView是ios开发中经经常使用到的控件,这里统一记录一下开发中遇到的经常使用小技巧,不断探索更新.也希望大家能够告诉我很多其它经常使用的小技巧啦~一起进步 1.去除多余的列表线条 ...

  4. IOS中TableView的用法

    一.UITableView 1.数据展示的条件 1> UITableView的所有数据都是由数据源(dataSource)提供的,所以要想在UITableView展示数据,必须设置UITable ...

  5. ios中tableview的移动添加删除

    // // MJViewController.m // UITableView-编辑模式 // // Created by mj on 13-4-11. // Copyright (c) 2013年 ...

  6. ios中tableview网封装(viewcontroller封装)常用的

    下载地址 http://pan.baidu.com/share/link?shareid=3657500168&uk=923776187 使用框架 1:asIHttpRequest库 2;SB ...

  7. IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态

    一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...

  8. IOS中TableView的使用(1) -创建一个简单的tableView

    创建一个简单的tableView: #import <UIKit/UIKit.h> /*tableView 一定要遵守这两个协议: UITableViewDataSource,UITabl ...

  9. iOS中tableView组头部或尾部标题的设置

    解决在tableView返回组标题直接返回字符串,带来的不便设置组标题样式的问题解决办法,设置尾部标题和此类似  // 返回组头部view的高度 - (CGFloat)tableView:(UITab ...

随机推荐

  1. 自定义View 水印布局 WaterMark 前景色 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  2. python对json的操作总结 zz

    Json简介:Json,全名 JavaScript Object Notation,是一种轻量级的数据交换格式.Json最广泛的应用是作为AJAX中web服务器和客户端的通讯的数据格式.现在也常用于h ...

  3. 通过经纬度坐标计算距离的方法(经纬度距离计算)ZZ

    通过经纬度坐标计算距离的方法(经纬度距离计算) 最近在网上搜索“通过经纬度坐标计算距离的方法”,发现网上大部分都是如下的代码: #define PI 3.14159265 static double ...

  4. Android推送分析

     cpu多核利用能够实现Android推送的吞吐量. 讲明白这点,我们需要了解Android推送的基本原理了.如果实现C(客户端)与server(客户端)实时通讯了.这里有两种思路了: 1.一种是定时 ...

  5. 在UTF-8中,一个汉字为什么需要三个字节?(转)

    http://www.cnblogs.com/web21/p/6092414.html UNICODE是万能编码,包含了所有符号的编码,它规定了所有符号在计算机底层的二进制的表示顺序.有关Unicod ...

  6. PowerShell获取当前用户的权限

      function Get-CurrentUserRoles {   $SecurityPrinciple = New-Object -TypeName System.Security.Princi ...

  7. ASP入门(十四)-FileSystemObject 对象

    File Access 组件中常见的对象有 FileSystemObject.TextStream.File.Folder.Drive等,其中每一个对象都有不同的属性和方法,我们将会在用到的时候进行详 ...

  8. 微信小程序 - 使用字体图标(阿里云库)

    实现 阿里图库:https://www.iconfont.cn/ CSS3:[attribute*=value] 选择器 步骤 1. 加入购物车 2. 下载代码解压,复制iconfont.css ap ...

  9. phpstudy部署thinkPHP

    利用phpstudy配置虚拟主机 Listen 8080 <VirtualHost _default_:80> DocumentRoot "D:\phpStudy\WWW&quo ...

  10. SourceTree安装教程

    一.安装Git 链接: http://pan.baidu.com/s/1mh7rICK 密码: 48dj 二.安装SourceTree 链接: http://pan.baidu.com/s/1skWk ...