#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. Linux下线程同步的几种方法

    Linux下提供了多种方式来处理线程同步,最常用的是互斥锁.条件变量和信号量. 一.互斥锁(mutex) 锁机制是同一时刻只允许一个线程执行一个关键部分的代码.  1. 初始化锁 int pthrea ...

  2. Direct I/O,Synchronous I/O的概念

    Direct I/O概念: Direct I/O is a way to avoid entire caching layer in the kernel and send the I/O direc ...

  3. ul里不能直接嵌套div(在ie7以前版本)

    平时为了写某个js效果,从而忽略了标签的嵌套 从而导致了IE6-7混乱,在ul下,直接嵌套div,在ie7以前版本,会出现的状况是:div会被离它最近的li包裹住. 请看dome <ul cla ...

  4. 计算GDOP

    #include <iostream> #include <fstream> #include "..\include\CPosition.h" #incl ...

  5. Android -- Camera.ShutterCallback

    干货 相机拍照的回调 /** * Equivalent to takePicture(shutter, raw, null, jpeg). * * @see #takePicture(ShutterC ...

  6. CSS命名规范和规则

    一.命名规则 ).尽量不缩写,除非一看就明白的单词 二.class的命名 (1).red { color: red; } .f60 {color: #f60; } .ff8600{ color: #f ...

  7. A Complete ActiveX Web Control Tutorial

    A Complete ActiveX Web Control Tutorial From: https://www.codeproject.com/Articles/14533/A-Complete- ...

  8. MySQL表级锁和行级锁

    一:概述 相对其他数据库而言,MySQL的锁机制比较简单,其最显著的特点是不同的存储引擎支持不同的锁机制.比如,MyISAM和MEMORY存储引擎采用的是表级锁(table-level locking ...

  9. jquery旋转图片

    今天介绍一款 jQuery 插件——jqueryrotate,它可以实现旋转效果.jqueryrotate 支持所有主流浏览器,包括 IE6.如果你想在低版本的 IE 中实现旋转效果,那么 jquer ...

  10. 15款不容错过的前端开发Javascript和css类库 - 2017版本~

    前端的JS和CSS类库日新月异, 在今天这篇介绍中,我们将精挑细选15款超棒的JS/CSS类库, 希望大家在开发过程中会觉得有帮助~ Core UI 基于Bootstrap4的一套UI类库, Core ...