tableView 折叠效果
来源:互联网 发布:速达软件数据库密码 编辑:程序博客网 时间:2024/04/30 15:48
#import <Foundation/Foundation.h>
@interface tableData : NSObject
@property (nonatomic,copy)NSString * title;
@property (nonatomic,strong)NSMutableArray * array;
@property (nonatomic,assign,readwrite)BOOL isShow;
@end
#import "aboutViewController.h"
#import "Header.h"
#import "tableData.h"
@interface aboutViewController ()<UITableViewDataSource,UITableViewDelegate>{
NSMutableArray * dataArray;
}
@property (nonatomic,strong)UITableView * infoTableView;
@end
@implementation aboutViewController
-(instancetype)init{
if (self = [superinit]) {
dataArray = [NSMutableArrayarray];
for (int i ='A'; i <= 'Z' ; i++) {
tableData * data = [[tableDataalloc]init];
data.title = [NSStringstringWithFormat:@"%d",i];
for (int a =0; a<6; a++) {
[data.array addObject:[NSString stringWithFormat:@"%d",a]];
}
[dataArray addObject:data];
}
}
return self;
}
-(void)setInfoTableView:(UITableView *)infoTableView{
if (_infoTableView != infoTableView) {
_infoTableView = infoTableView;
_infoTableView.dataSource =self;
_infoTableView.delegate =self;
[self.viewaddSubview:_infoTableView];
}
}
- (void)viewDidLoad {
[superviewDidLoad];
[self setData];
[self setUI];
}
-(void)setData{
}
-(void)setUI{
self.view.backgroundColor = [UIColorgrayColor];
UITableView * tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,0, SCR_WIDTH,SCR_HEIGHT)style:UITableViewStylePlain];
self.infoTableView = tableView;
}
#pragma mark tableView 代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
returndataArray.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if ([[dataArrayobjectAtIndex:section] isShow]) {
return [[[dataArrayobjectAtIndex:section] array] count];
}else{
return 0;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 80;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * cellid =@"cellid";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellid];
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:cellid];
}
cell.textLabel.text =@"test";
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"%@",indexPath);
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UILabel * label = [[UILabelalloc]initWithFrame:CGRectMake(0,0, SCR_WIDTH,30)];
label.backgroundColor = [UIColororangeColor];
label.tag = 1000 + section;
UITapGestureRecognizer * tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapClick:)];
label.userInteractionEnabled =YES;
tap.numberOfTapsRequired =1;
tap.numberOfTouchesRequired =1;
[label addGestureRecognizer:tap];
label.text = @"点我";
return label;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
if ([[dataArrayobjectAtIndex:section] isShow]) {
return 0;
}else{
return 1;
}
}
-(void)tapClick:(UITapGestureRecognizer*)sender{
UILabel * label = (UILabel *)sender.view;
int tag = label.tag -1000;
tableData * data = [dataArrayobjectAtIndex:tag];
data.isShow = !data.isShow;
[dataArrayreplaceObjectAtIndex:tag withObject:data];
[self.infoTableViewreloadData];
}
@end
- tableView 折叠效果
- tableview折叠效果
- 刷新tableView单行 实现折叠效果
- TableView 展开和折叠
- 简单实现tableView折叠列表
- tableview的展开和折叠
- 选择屏幕折叠效果
- 内容折叠效果
- jQuery实现折叠效果
- 手风琴折叠效果
- UITableView的折叠效果
- QQ折叠效果
- Android 折叠效果示例
- Android 折叠效果示例
- 自定义UITableView折叠效果
- Bootstrap折叠效果学习
- UITableView 折叠效果 masksToBounds
- 自定义UITableView折叠效果
- oracle中的分析函数的使用
- Win7X64下Qt560+MinGW492+OpenCV2412+Cmake351编译环境搭建
- vb
- 对Handler的理解
- tomcat运行一段时间后,org.apache.jk.common.ChannelSock报错java.lang.IndexOutOfBoundsExcept
- tableView 折叠效果
- oracle锁概念 与 v$parameter字段介绍
- JNI - Getting Started
- 对任意10个随机数求和(3)
- swift 微信支付接口实现
- mongodb3.0.3集群分片搭建
- Android测试详解_1-Best Practices for Testing-介绍
- 正则表达式(适用于oracle及linux)
- 零基础myeclipse下springBoot+maven+thymeleaf的开发(1)