IOS UITableView总结
来源:互联网 发布:数据集成工具 编辑:程序博客网 时间:2024/05/18 03:02
UITableView需结合UITableView的两个代理协议共同使用 <UITableViewDelegate,UITableViewDataSource>
在定义UITableView时,需同时设置其代理
tableView.delegate = self; tableView.dataSource = self;
UITableView有两种类型,在初始化时就可以设置(下面这个是UITableView的初始化函数):
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER; // must specify style at creation. -initWithFrame: calls this with UITableViewStylePlain
UITableViewStylePlain, // regular table view UITableViewStyleGrouped // preferences style table view一种是普通类型(如IOS里面的便笺),另一种是分组类型(如IOS里面的设置)
二、UITableView的协议函数
1.设置UITable的组数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
2.设置UITableView每组的个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
3.设置每组的头部(尾部)名称
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
5.给头部(尾部)添加视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath注意:在每一个cell里面,可以引用这样的格式,然后再设置他的视图(文本),最后返回cell
NSString *strID = @"ID"; //尝试获取可以复用的单元格 //如果得不到,返回nil UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:strID]; if (cell == nil) { cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strID]; }
7.自动调整自视图的大小
@property(nonatomic) UIViewAutoresizing autoresizingMask;
8.设定进行重新加载的函数
- (void)reloadData; // reloads everything from scratch. redisplays visible rows. because we only keep info about visible rows, this is cheap. will adjust offset if table shrinks
9.UITableView设置数据心得
如果有多组数据,可以使用字典的方式把字符串和array联系在一起!!!
阅读全文
0 0
- IOS UITableView 使用总结
- iOS-UITableView方法总结
- iOS UITableView 总结
- iOS UITableView 使用总结
- IOS UITableView总结
- iOS - UITableView性能优化总结
- IOS中UITableView使用总结
- IOS中UITableView使用总结
- iOS UITableView reloadData问题总结
- iOS开发 -- UITableView 完整知识点总结(一)
- 【iOS开发】 UITableView SDK所有方法总结
- iOS开发UITableView基本使用方法总结
- iOS开发UITableView基本使用方法总结
- iOS开发UITableView基本使用方法总结
- iOS UITableView(七) cell删除总结
- iOS中UITableView中使用总结
- IOS UITableView 常见问题总结(-)
- iOS中UITableView使用总结和 iOS UITableView代理方法详解
- Android----AsyncTask和Handler对比
- 1>> socketserver 学习
- jsp基础语法
- 合法括号子段 51Nod
- 浅谈unsigned int与int相加的问题
- IOS UITableView总结
- servlet 笔记
- 方格取数(2) (最小割)
- FFT学习笔记<代码篇>
- Nature:拟南芥微生物组功能研究0概述
- 讯飞语音空指针错误
- HTML页面自适应宽度的table(表格)
- opencv将整数像素图片转化为浮点型
- 【Gym