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 ...
随机推荐
- Win7 SP1语言包微软官方下载地址及使用方法 2
情形一:如果您的系统版本是企业版.旗舰版,可以在Windows update中检测语言包按照提示下载安装即可.如果觉得Windows update不方便的话,可以在本文第二部分中下载所需的语言包,下载 ...
- 实现jsp网站添加到收藏夹
var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd': 'CTRL'; ...
- Win7 x64下进程保护与文件保护(ObRegisterCallbacks)
进程保护部分参考 http://bbs.pediy.com/showthread.php?t=168023 进程保护,在任务管理器不能结束进程 #ifndef CXX_PROTECTPROCESSX6 ...
- uva 558 - Wormholes(Bellman Ford判断负环)
题目链接:558 - Wormholes 题目大意:给出n和m,表示有n个点,然后给出m条边,然后判断给出的有向图中是否存在负环. 解题思路:利用Bellman Ford算法,若进行第n次松弛时,还能 ...
- 导入flash 逐帧动画
只要图片是一序列的,比如0001-0100,就可以使用导入素材功能,选择第一张图片,选中影片剪辑并编辑然后点击导入到舞台,然后FlashCS6工具就会问你,这是一序列图片,是否逐帧导入,点是,就ok了 ...
- Java中String对象的不可变性
首先看一个程序 package reverse; public class Reverse { public static void main(String[] args) { String c1=n ...
- PL/pgSQL学习笔记之七
http://www.postgresql.org/docs/9.1/static/plpgsql-declarations.html 如果一个PL/pgSQL函数声明了输出参数,输出参数被赋予$n名 ...
- hdu 4597 Play Game 区间dp
Play Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=459 ...
- [连载]JavaScript讲义(05)--- 数据处理
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvamFja2ZydWVk/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- 一步步学Mybatis-告别繁琐的配置之Mybatis配置文件生成工具 (7)
今年是2013年的杀青之日,前几天由于比较忙,没有及时更新本篇的最后一篇东西,前六篇中我们主要都是采用手动配置相关的Mybatis映射文件与相应的接口类与实体类.当然如果在真正的使用过程中,由于业务的 ...