iOS - UI - UITableView
服从数据源 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {}返回的视图推不上去
但是tableHeaderView 可以推上去
UITableView * tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
//普通
UITableViewStylePlain,
//分组
UITableViewStyleGrouped
//设置数据源
tableView.dataSource = self;
//设置代理
tableView.delegate = self;
//得到所有选中的行数
[self.tableView indexPathsForSelectedRows];
//分区头的高度 默认20
tableView.sectionHeaderHeight = 30;
//分区尾的高度 默认20
tableView.sectionFooterHeight = 30;
//行高,默认行高是44。
tableView.rowHeight = 100;
tableView.backgroundColor = [UIColor grayColor];
//设置背景View
UIImageView * imageView = [[UIImageView alloc] initWithFrame:tableView.bounds];
imageView.image = [UIImage imageNamed:@"baby.jpg"];
tableView.backgroundView = imageView;
//取消选中某一行
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCellSeparatorStyleNone 没有线 UITableViewCellSeparatorStyleSingleLine 单行线 UITableViewCellSeparatorStyleSingleLineEtched 被石化的单行线
//线的风格
_tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
//线的内边距
_tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
//索引区域的背景
_tableView.sectionIndexBackgroundColor = [UIColor whiteColor];
//设置索引文字的颜色
_tableView.sectionIndexColor = [UIColor blueColor];
//cell行数小于多少是展示索引
_tableView.sectionIndexMinimumDisplayRowCount = 100;
//选择索引时的背景颜色
_tableView.sectionIndexTrackingBackgroundColor = [UIColor clearColor];
//显示索引的题目
- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [self.dataList valueForKey:@"title”];
sep//设置单元格文本
cell.textLabel.text = wechat.title;
//设置单元格 左边视图
cell.imageView.image = [UIImage imageNamed:wechat.icon];
//选中风格
UITableViewCellSelectionStyleNone, //没有点中效果
UITableViewCellSelectionStyleBlue, ==
UITableViewCellSelectionStyleGray, ==
UITableViewCellSelectionStyleDefault
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
//设置cell右端图标
UITableViewCellAccessoryDisclosureIndicator 尖角号
UITableViewCellAccessoryDetailDisclosureButton 圆圈感叹号加尖角号
UITableViewCellAccessoryCheckmark 对号
UITableViewCellAccessoryDetailButton 圆圈感叹号
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//UITableViewCellStyle 单元格风格
UITableViewCellStyleDefault 显示图片,显示辅助图片,显示一行文字
UITableViewCellStyleValue1 显示图片,显示辅助图片,普通文字,描述文字,共占一排
UITableViewCellStyleValue2 不显示图片,显示辅助图片,普通文字,描述文字,共占一排
UITableViewCellStyleSubtitle 显示图片,显示辅助图片,普通文字,描述文字,共占两排
//设置描述文字
cell.detailTextLabel.text = industry.state;
static NSString * identifier = @"cellID";
//从复用池里找对应的cell
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cellID"];
}
3、UITableViewDataSource 数据源
//cell单元格,IndexPath索引 UITableViewCell是组成UITableView的单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
//Section是几组,Rows多少行(每组内有多少元素),默认情况下只有一个Section.分组的index为0(每一分组多少行)
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
//返回分区顶部标题
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section ;
//返回分区尾部标题
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section ;
//返回单元格的组数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
//返回表格视图是否可以编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath ;
//返回表格视图是否可以滚动
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath ;
4、UITableViewDelegate 代理方法
//选中某一行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}
//设置分区头部视图
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
//设置分区尾部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {}
//当滚动表格时,这个代理方法,一直调用
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}
//设置行高方法,如果实现这个代理方法,rowHeight无效,这个主要用于设置可变cell高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
//修改左侧滑动删除方法
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
iOS - UI - UITableView的更多相关文章
- [IOS]IOS UI指南
[IOS]IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻 ...
- iOS中UITableView的cell点击事件不触发didSelectRowAtIndexPath(汇总)
iOS中UITableView的cell点击事件不触发didSelectRowAtIndexPath 首先分析有几种原因,以及相应的解决方法 1.UITableViewCell的userInterac ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- 国外IOS UI指南
国外IOS UI指南 众所周知,IOS的界面设计,越来越流行,可以说都形成了一个标准,搜集了一些资料,供自己以后学习使用! iOS Human Interface Guidelines (中文翻译) ...
- iOS UI的几种模式
iOS UI的几种模式: 1.平凡模式(原生控件组合): 2.新闻模式: 3.播放器模式: 4.微博模式:
- 通过实现一个TableView来理解iOS UI编程
推荐一篇神作: 通过实现一个TableView来理解iOS UI编程 http://blog.jobbole.com/61101/
- iOS programming UITableView and UITableViewController
iOS programming UITableView and UITableViewController A UITableView displays a single column of dat ...
- IOS之UI -- UITableView -- 1 -- 相关初识
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- IOS UI 第九篇: UITABLEVIEW
学英语.所以用英文来记录笔记. Define the dataSource: @implementation ViewController{ NSMutableArray *dataSo ...
随机推荐
- json的一些问题
使用json不仅可以这么写,{"ARCHIVAL_CODE":"String","TDQLR":"String"} 还可 ...
- [网络]远程访问局域网svn服务器[转]
转至:http://8474832.blog.51cto.com/8464832/1555449 打开路由器访问界面 选择转发规则->端口映射-新建 在弹出的界面中填写相应的端口号了内网ip 填 ...
- css 关于两栏布局,左边固定,右边自适应
好几个星期都没写博客了,最近不忙也不闲,稀里糊涂过了两个星期,之前几个月内天天坚持签到.最近也没签到.哈哈,说正事. 今天做东钿互金平台后台页面,昨天做了一个登录页面,业偶碰到了一个难题.等下也要把它 ...
- C++开发必看 四种强制类型转换的总结 [转]
一.C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是: TYPE b = (TYPE)a 二.C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. co ...
- Linux 上的基础网络设备详解
抽象网络设备的原理及使用 网络虚拟化是 Cloud 中的一个重要部分.作为基础知识,本文详细讲述 Linux 抽象出来的各种网络设备的原理.用法.数据流向.您通过此文,能够知道如何使用 Linux 的 ...
- Spring+Struts+Ibatis的配置
指定Spring配置文件位置 <context-param> <param-name>contextConfigLocation</param-name> < ...
- mysql修改用户密码 新增用户
修改密码: mysql> grant all privileges on *.* to yongfu_b@'192.168.1.%' identified by 'my_password_new ...
- C++学习笔记之模板(1)——从函数重载到函数模板
一.函数重载 因为函数重载比较容易理解,并且非常有助于我们理解函数模板的意义,所以这里我们先来用一个经典的例子展示为什么要使用函数重载,这比读文字定义有效的多. 现在我们编写一个交换两个int变量值得 ...
- android学习记录(十三)Task 和 Activity 回退栈操作。
首先说一下Task是一个什么概念吧:Task是一个包括activity的列表.没 错.简单的说就是依照启动的先后来排队的一个队列.Back Stack.就是回退栈的意思:那么有什么用?Back Sta ...
- boost 线程、互斥体、条件变量
1.任何技术都是针对特定场景设计的,也就是说,为了解决某个问题而设计的. 2.考虑下面一种场景:一个小旅馆,只有一个卫生间,有清洁人员,店主人,和旅客.卫生间用完之后,就会自动锁闭,必须取钥匙,才能进 ...