12-27 UITableView常用属性及方法
UITableView也有自己的代理协议,它本身继承自UIScrollView
一:代理要遵守代理协议<UITableViewDelegate>,代理协议中的代理方法:
1.改变某一行的行高:(返回是某一索引的行高)
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

执行完毕后,会使得偶数行的行高为60,奇数行为100;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
(后面会用到)
// Called after the user changes the selection.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
NS_AVAILABLE_IOS(3_0);
二:UITableView的常用属性
1、可以用连线的方式设置数据源和代
self.tableView.dataSource
self.tableView.delegate
2、设置行高
self.tableView.rowHeight = 60;
@property (nonatomic) CGFloat rowHeight; //default value if unset
@property (nonatomic) CGFloat sectionHeaderHeight// default value if unset
@property (nonatomic) CGFloat sectionFooterHeight// default value if unset
3、设置分割线
1).separatorInset属性:
是设定分割线的上左下右的间距的属性,具体代码和效果如下
self.tableView.separatorInset = UIEdgeInsetsMake(0, 10, 0, 10);
self.tableView.separatorColor = [UIColor blackColor];

self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
self.tableView.separatorColor = [UIColor blackColor];

2).设置分割线风格
@property(nonatomic) UITableViewCellSeparatorStyle ;
4、设置tableView是否分组(默认在storyboard中已经设置) @property (nonatomic, readonly) UITableViewStyle
UITableViewStylePlain,
UITableViewStyleGrouped
*separatorColor;
style;
5、自定义头和尾部
1)设置头
@property(nonatomic,retain) UIView *tableHeaderView;
//above row content. default is nil. not to be confused with section header
//给头加一个ContactAdd的按钮
self.tableView.tableHeaderView = [UIButton buttonWithType:UIButtonTypeContactAdd];
效果
@property(nonatomic,retain) UIView *tableFooterView;
//content. default is nil. not to be confused with section footer
12-27 UITableView常用属性及方法的更多相关文章
- UITableView常用属性和方法 - 永不退缩的小白菜
UITableView常用属性和方法 - 永不退缩的小白菜 时间 2014-05-27 01:21:00 博客园精华区原文 http://www.cnblogs.com/zhaofucheng11 ...
- ios基础篇(四)——UILabel的常用属性及方法
UILabel的常用属性及方法:1.text //设置和读取文本内容,默认为nil label.text = @”文本信息”; //设置内容 NSLog(@”%@”, label.text); //读 ...
- SVG DOM常用属性和方法介绍(1)
12.2 SVG DOM常用属性和方法介绍 将以Adobe SVG Viewer提供的属性和方法为准,因为不同解析器对JavaScript以及相关的属性和方法支持的程度不同,有些方法和属性是某个解析 ...
- 第190天:js---String常用属性和方法(最全)
String常用属性和方法 一.string对象构造函数 /*string对象构造函数*/ console.log('字符串即对象');//字符串即对象 //传统方式 - 背后会自动将其转换成对象 / ...
- JavaScript中Number常用属性和方法
title: JavaScript中Number常用属性和方法 toc: false date: 2018-10-13 12:31:42 Number.MAX_VALUE--1.79769313486 ...
- UIScrollView,UICollectionView 和UITableView的属性和方法
UIScrollView,UICollectionView 和UITableView 三者之间的关系:UIScrollView是 UICollectionView 和 UITableView 的父类. ...
- Node.js process 模块常用属性和方法
Node.js是常用的Javascript运行环境,本文和大家发分享的主要是Node.js中process 模块的常用属性和方法,希望通过本文的分享,对大家学习Node.js http://www.m ...
- UIView的一些常用属性和方法
UIView的一些常用属性和方法 1. UIView的属性 UIView继承自UIResponder,拥有touches方法. - (instancetype)initWithFrame:(CGRec ...
- UIView常用属性与方法/UIKit继承结构
UIView常用属性与方法 @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDy ...
随机推荐
- Spring表达式语言 之 5.3 SpEL语法(拾肆)
5.3 SpEL语法 5.3.1 基本表达式 一.字面量表达式: SpEL支持的字面量包括:字符串.数字类型(int.long.float.double).布尔类型.null类型. 类型 示例 字 ...
- kmeans算法原理以及实践操作(多种k值确定以及如何选取初始点方法)
kmeans一般在数据分析前期使用,选取适当的k,将数据聚类后,然后研究不同聚类下数据的特点. 算法原理: (1) 随机选取k个中心点: (2) 在第j次迭代中,对于每个样本点,选取最近的中心点,归为 ...
- [saiku] 连接 mondrain 数据源出错-空指针错误
我的个亲娘,这个问题查半天终于查出来了. 一开始以为是配置的mysql的location连接有问题,各种修改啊各种尝试,还是不行. 好死不死报了空指针错误,让人无法下手. 后来发现是这样子的: 生成s ...
- [转载]Soap安全测试入门
http://www.cnblogs.com/zerotest/p/4670902.html 在SoapUI4.0引入的安全测试特点使它非常容易为你来验证你的目标服务的功能性安全,就可以评估您的系统常 ...
- cf(#div1 B. Dreamoon and Sets)(数论)
B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 自定义jQuery插件Step by Step
1.1.1 摘要 随着前端和后端技术的分离,各大互联网公司对于 Mobile First理念都是趋之若鹜的,为了解决网页在不同移动设备上的显示效果,其中一个解决方案就是Responsive Desig ...
- uva 1631
1631 Locker A password locker with N digits, each digit can be rotated to 0-9 circularly. You can ro ...
- windows系统下Tomcat与Apache服务器集成
说明:此文是看书真实试验成功的,书中提到了不同版本不兼容的问题,但是很荣幸我没碰到,此例可供参考. 本文假设你已经有了java环境和tomcat,你已经熟悉tomcat的应用. Jdk 1.7.0_5 ...
- Apache Thrift - 可伸缩的跨语言服务开发框架
To put it simply, Apache Thrift is a binary communication protocol 原文地址:http://www.ibm.com/developer ...
- POJ 1050 To the Max 暴力,基础知识 难度:0
http://poj.org/problem?id=1050 设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和 首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x ...