iOS UITableView简介 —— HERO博客
来源:互联网 发布:淘宝产品拍摄相机选择 编辑:程序博客网 时间:2024/05/11 14:50
UITableView简介:
UITableView是iOS中使用最广泛的控件,继承UIScrollView,是一个一维的表格(只有行)。
UITableView属性:
UITableViewCellStyleDefault:样式,左侧显示textLabel(不显示detailTextLabel),imageView可选(显示在最左边)
UITableViewCellStyleValue1:样式,左侧显示textLabel、右侧显示detailTextLabel(默认蓝色),imageView可选(显示在最左边)
UITableViewCellStyleValue2:样式,左侧依次显示textLabel(默认蓝色)和detailTextLabel,imageView可选(显示在最左边)
UITableViewCellStyleSubtitle:样式,左上方显示textLabel,左下方显示detailTextLabel(默认灰色),imageView可选(显示在最左边)
UITableViewDataSource、UITableViewDelegate:代理协议
cell:展示的内容,可复用
contentView:UITableViewCell内部默认的子视图,contentView是UITableViewCell所显示内容的父视图,可显示一些辅助指示视图,contentView下默认有3个子视图,其中2个是UILabel(通过UITableViewCell的textLabel和detailTextLabel属性访问),第3个是UIImageView(通过UITableViewCell的imageView属性访问)
UITableView使用:
//创建cell
static NSString *identifier = @"identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:identifier];
}
#pragma mark - Table view data source
//组数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//组中行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//cell内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//小按钮点击事件
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
//设置头部标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
//设置尾部标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
//设置行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//是否允许行移动
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
//能否滑动
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
//删除按钮的名字
- (NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
//编辑
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
- iOS UITableView简介 —— HERO博客
- iOS UIScrollView简介 —— HERO博客
- iOS UICollectionView简介 —— HERO博客
- iOS UITextField简介 —— HERO博客
- iOS UIDynamic简介 —— HERO博客
- iOS UISearchBar简介 —— HERO博客
- iOS UITableView使用练习 —— HERO博客
- iOS UITableView添加长按事件 —— HERO博客
- iOS UITableView性能优化 —— HERO博客
- iOS Touch ID指纹识别技术简介 —— HERO博客
- iOS 基于MVC设计模式练习UITableView使用 —— HERO博客
- iOS 基于MVVM设计模式练习UITableView使用 —— HERO博客
- iOS 图文混排,UITableView实现图文混排 —— HERO博客
- iOS 添加字体库 —— HERO博客
- iOS MD5加密 —— HERO博客
- iOS 预产期计算器 —— HERO博客
- iOS UISearchBar使用 —— HERO博客
- iOS 自定义日历 —— HERO博客
- 基于Bundle的消息传递
- ListView实现颜色变化的单选效果
- [BLE]低功耗蓝牙介绍
- 如何在folat left的时候让子div撑开父div
- 安卓通知的使用系列1:土司(Toast)通知和自定义土司(Toast)通知
- iOS UITableView简介 —— HERO博客
- p6spy2.x配置为slf4j-log4j输出日志同时到控制台和文件
- 225. Implement Stack using Queues
- 禁止UIScrollView垂直方向滚动,只允许水平方向滚动;或只允许垂直方向滚动
- spring ioc 原理小解
- Java的反射机制的作用
- 南阳ACM 题目71:独木舟上的旅行 Java版
- Android控件postDelayed用法,View自带的定时器
- c++自制Redis 数据库(十四)阶段性小结