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 ...
随机推荐
- 用网站(WebSite而不是WebProject)项目构建ASP.NET MVC网站
从ASP.NET MVC第一个版本开始到现在,创建ASP.NET MVC项目的官方方法只有一个,“文件”->“新建”->“项目”,然后选择ASP.NET MVC X Web应用程序. 这种 ...
- Longest Palindromic Substring leetcode java
题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum l ...
- 组件化 得到 DDComponent JIMU 模块 插件 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- 揭秘uc浏览器二
这节,四个议题: ①一个网页显示在webview控件中 ②如何正常隐藏显示标题栏. ③如何用runnable来隐藏标题栏,这样子就更加的专业化. ④上节我们说道了QuickActionGrid,看他长 ...
- python2.7 调用 .net的webservice asmx
首先安装pip install suds 或下载:https://pypi.org/project/suds-jurko/0.6/#files 这个是最新版本 由于不支持python3.6, 所以只能 ...
- 【Java】Java-正则匹配-性能优化
Java-正则匹配-性能优化 Java 正则 点_百度搜索 在Java类中如何用正则表达式表示小数点啊?_百度知道 使用Jakarta-ORO库的几个例子 - 小橡树 - ITeye博客 正则表达式以 ...
- 使用新版SDK不想跳转微博客户端能否直接发送微博分享?
如题啊如题! 新版本中没有StatusesAPI?????
- Mysql写入中文出错
本地调试好像正常,服务器运行报错: UnicodeEncodeError: 'latin-1' codec can't encode character u'\u5206' in position 2 ...
- [Docker] Hooking a Volume to Node.js Source Code
Normally when you create a Volume, it will store in Docket Host, you can also tell the folder which ...
- 推荐一款jQuery ColorPicked 颜色拾取器插件
先看实现的效果图, 本文底部有完整demo 不想看我墨迹的可以跳过了^_^. 官网地址:http://www.eyecon.ro/colorpicker/#about 代码SVN 地址:https:/ ...