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 ...
随机推荐
- DP练习(概率,树状,状压)
http://vjudge.net/contest/view.action?cid=51211#overview 花了好长时间了,终于把这个专题做了绝大部分了 A:HDU 3853 最简单的概率DP求 ...
- jQuery plugins 图片上传
http://plugins.jquery.com/ 用到一下插件: magnific popup 看大图 jQuery File Upload 多文件上传 jQuery Rotate 图片旋转 gi ...
- libcurl API:CURLOPT_REFERER的用法
1.当你用libcurlAPI来请求某些数据时,发现返回的数据是0,这时候你就要去尝试用CURLOPT_REFERER来伪造一个来路页面:具体设置什么值可以通过浏览器来获取:按f12,在network ...
- 习总强调网络安全 ,咱们国产SSL证书必须加快普及速度
上海(2014 年 2 月 27 日)—— 央视新闻联播 27 日报道中央网络安全和信息化领导小组于当日成立的消息及习总在该小组首次会议上的重要讲话.据悉,该小组由习总任小组长,李克强.刘云山任副组长 ...
- Background Worker Component
http://www.delphiarea.com/products/delphi-components/backgroundworker/ Background Worker Component ( ...
- X431 元征诊断枪
X-431 Diagun是专门为汽车维修技师设计的诊断设备. 小巧的主机.强大的诊断功能.方便快捷的网上升级.一体化多功能接头,都是维修技师的首选.X-431 Diagun 是汽车维修技师的标准装备. ...
- jQuery生成全页面的悬浮覆盖层效果(overlay)
可能在大家开发的过程中,往往需要自己生成一个全页面的覆盖层,以便让用户能够把注意力专注于开发者指定的某一个区域,在这里开发小技巧里,我们使用非常简单的代码生成类似的效果,如下: $("#ov ...
- Microsoft SQL Server 2008 基本安装说明
Microsoft SQL Server 2008 基本安装说明 安装SQL2008的过程与SQL2005的程序基本一样,只不过在安装的过程中部分选项有所改变,当然如果只熟悉SQL2000安装的同志来 ...
- jquery 新建的元素事件绑定问题
js的事件监听跟css不一样,css只要设定好了样式,不论是原来就有的还是新添加的,都有一样的表现.而事件监听不是,你必须给每一个元素单独绑定事件. 常见的例子是处理表格的时候.每行行末有个删除按钮, ...
- BZOJ 4318: OSU! 期望DP
4318: OSU! 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4318 Description osu 是一款群众喜闻乐见的休闲软件 ...