iOS实现表格(非TableView)
来源:互联网 发布:淘宝店铺号及二维码 编辑:程序博客网 时间:2024/05/22 13:01
WhdeForm
iOS 表格项目地址:https://github.com/whde/WhdeForm
pod 'WhdeForm', '~> 1.0.0'
- 添加了
Reusable
机制 - 添加了横(
Section
)表头 - 添加了竖(
Column
)表头 - 添加了左上角(
TopLeftHeader
)总表头 - 通过
FDateSource
去创建各个元素,类似TableView
- 添加了
FIndexPath,{section, column}
- 表头添加点击事件
- 添加了网格
使用
#import "ViewController.h"#import "FormScrollView.h"@interface ViewController ()<FDelegate, FDataSource> { NSArray *_data;}@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; self.edgesForExtendedLayout = UIRectEdgeNone; self.view.autoresizingMask = UIViewAutoresizingNone; FormScrollView *table = [[FormScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-64)]; table.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); table.fDelegate = self; table.fDataSource = self; [self.view addSubview:table]; _data = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"datas" ofType:@"plist"]]; [table reloadData];}- (FTopLeftHeaderView *)topLeftHeadViewForForm:(FormScrollView *)formScrollView { FTopLeftHeaderView *view = [formScrollView dequeueReusableTopLeftView]; if (view == NULL) { view = [[FTopLeftHeaderView alloc] initWithSectionTitle:@"行数" columnTitle:@"列数"]; } return view;}- (NSInteger)numberOfSection:(FormScrollView *)formScrollView { return _data.count;}- (NSInteger)numberOfColumn:(FormScrollView *)formScrollView { return 100;}- (CGFloat)heightForSection:(FormScrollView *)formScrollView { return 44;}- (CGFloat)widthForColumn:(FormScrollView *)formScrollView { return 80;}- (FormSectionHeaderView *)form:(FormScrollView *)formScrollView sectionHeaderAtSection:(NSInteger)section { FormSectionHeaderView *header = [formScrollView dequeueReusableSectionWithIdentifier:@"Section"]; if (header == NULL) { header = [[FormSectionHeaderView alloc] initWithIdentifier:@"Section"]; } [header setTitle:[NSString stringWithFormat:@"第%ld行", (long)section] forState:UIControlStateNormal]; /*[header setBackgroundColor:[UIColor redColor]];*/ [header setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; return header;}- (FormColumnHeaderView *)form:(FormScrollView *)formScrollView columnHeaderAtColumn:(NSInteger)column { FormColumnHeaderView *header = [formScrollView dequeueReusableColumnWithIdentifier:@"Column"]; if (header == NULL) { header = [[FormColumnHeaderView alloc] initWithIdentifier:@"Column"]; } [header setTitle:[NSString stringWithFormat:@"第%ld列", (long)column] forState:UIControlStateNormal]; /*[header setBackgroundColor:[UIColor greenColor]];*/ [header setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; return header;}- (FormCell *)form:(FormScrollView *)formScrollView cellForColumnAtIndexPath:(FIndexPath *)indexPath { FormCell *cell = [formScrollView dequeueReusableCellWithIdentifier:@"Cell"]; NSLog(@"%@", cell); if (cell == NULL) { cell = [[FormCell alloc] initWithIdentifier:@"Cell"]; static int i=0; i++; NSLog(@"%d--%ld", i, (long)indexPath.section); } NSDictionary *dic = [_data objectAtIndex:indexPath.section]; [cell setTitle:dic[@"name"] forState:UIControlStateNormal]; [cell setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; /*[cell setBackgroundColor:[UIColor yellowColor]];*/ return cell;}- (void)form:(FormScrollView *)formScrollView didSelectSectionAtIndex:(NSInteger)section { NSLog(@"Click Section At Index:%ld", (long)section);}- (void)form:(FormScrollView *)formScrollView didSelectColumnAtIndex:(NSInteger)column { NSLog(@"Click Cloumn At Index:%ld", (long)column);}- (void)form:(FormScrollView *)formScrollView didSelectCellAtIndexPath:(FIndexPath *)indexPath { NSLog(@"Click Cell At IndexPath:%ld,%ld", (long)indexPath.section, (long)indexPath.column);}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];}@end
0 0
- iOS实现表格(非TableView)
- tableview实现静态表格(xib版)
- ios tableview多种表格形式
- iOS开发表格TableView的使用
- 编辑表格@tableView实现分区,索引
- IOS非主线程更新界面tableview
- ios实现两个tableview联动
- ios实现两个tableview联动
- IOS TableView实现省市联动
- tableview实现静态表格(纯代码)组头组尾实现
- iOS TableView实现QQ好友列表(一)
- iOS TableView实现QQ好友列表(二)
- iOS TableView实现QQ好友列表(三)
- iOS TableView实现QQ好友列表(一)
- iOS TableView实现QQ好友列表(二)
- iOS TableView实现QQ好友列表(三)
- 编辑表格@tableView实现增加、删除、移动的操作
- IOS之tableview 实现动态加载图片
- iOS 网络编程之TCP/IP <四> 根据协议解析数据
- 瞬驰(Dash)D1开发手册--Raspberry Pi之开机启动
- 计算n!的位数<Math>
- 微软下载http://www.itellyou.cn/,系统、MSDN等
- Spring4 集成 Hibernate3 使用 HibernateTemplate 和使用 HibernateDaoSupport 操作对象
- iOS实现表格(非TableView)
- 传输表空间迁移数据步骤
- 支付宝-即时到账交易接口
- 网站添加数据出错,原来是MS SQL Server2008日志文件占据空间过大导致的
- java 配置文件操作工具
- 关于Linux系统的swap交换空间
- CGContextRef详解
- MySQL 主从同步设置
- mac下开发工具