1.继承链:UIScrrollView:UIview:UIresponder:NSObject

2.创建实例的时候首先需要确定table的类型

3.一个tableview对象必须要有一个数据源和一个委托对象,所以需要遵守 UITableViewDataSource和 UITableViewDelegate的协议

4.初始化一个tableview对象

- (instancetype)initWithFrame:(CGRect)frame
                        style:(UITableViewStyle)style

5.配置一个table view

    (1)@property(nonatomic, readonly) UITableViewStylestyle  :只读,返回table view的style

    (2)- (NSInteger)numberOfRowsInSection:(NSInteger)section  :返回一个特定部分的行数

    (3)@property(nonatomic, readonly) NSIntegernumberOfSections  :只读,返回部分的数量

    (4)@property(nonatomic) CGFloatrowHeight  :设置行的高度

    (5)@property(nonatomic) UITableViewCellSeparatorStyleseparatorStyle  :设置表格单元使用的分隔线

    (6)@property(nonatomic, strong) UIColor*separatorColor  :设置分隔线的颜色

    (7)@property(nonatomic, copy) UIVisualEffect*separatorEffect  :应用在表格分隔线的效果

    (8)@property(nonatomic, strong) UIView*backgroundView  :设置表格的背景视图

    (9)@property(nonatomic) UIEdgeInsetsseparatorInset  :设置线是否占满

    (10)@property(nonatomic) BOOL cellLayoutMarginsFollowReadableWidth  :A Boolean value that indicates whether the cell margins are derived from the width of the readable content guide.

6.创建表格视图单元:

    (1)- (void)registerNib:(UINib *)nib
forCellReuseIdentifier:(NSString *)identifier

nib

A nib object that specifies the nib file to use to create the cell.

identifier

The reuse identifier for the cell. This parameter must not be nil and must not be an empty string.

注册一个包含指定标示符TableView的Cell的nib对象

    (2)- (void)registerClass:(Class)cellClass
forCellReuseIdentifier:(NSString *)identifier

cellClass

The class of a cell that you want to use in the table.

identifier

The reuse identifier for the cell. This parameter must not be nil and must not be an empty string.

注册一个类用来创建新的Cell

(3)使用指定的标示符返回可重用的Cell

1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath
2 //Available in iOS 6.0 and later.

Apple重要提示:使用这个方法之前必须是使用了registerNib:forCellReuseIdentifier:  或者 registerClass:forCellReuseIdentifier:方法注册了Cell

(4)使用指定的标示符返回可重用的Cell

1 - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier

7.存取头文件和脚本

    (1)- (void)registerNib:(UINib *)nib
forHeaderFooterViewReuseIdentifier:(NSString *)identifier

nib

A nib object that specifies the nib file to use to create the header or footer view. This parameter cannot be nil.

identifier

The reuse identifier for the header or footer view. This parameter must not be nil and must not be an empty string.

注册一个包含表头或表尾的指定标示符表视图的nib对象,可重用

    (2)- (void)registerClass:(Class)aClass
forHeaderFooterViewReuseIdentifier:(NSString *)identifier

aClass

The class of a header or footer view that you want to use in the table.

identifier

The reuse identifier for the header or footer view. This parameter must not be nil and must not be an empty string.

注册一个类,用来创建新的包含表头或表尾的表视图

    (3)- (__kindofUITableViewHeaderFooterView *)dequeueReusableHeaderFooterViewWithIdentifier:(NSString*)identifier  :返回一个指定标识符的可重用的附带表头表尾的视图

    (4)@property(nonatomic, strong) UIView*tableHeaderView  :设置或返回该表格的表头视图

    (5)@property(nonatomic, strong) UIView*tableFooterView  :设置或返回该表格的表尾视图

    (6)@property(nonatomic) CGFloatsectionHeaderHeight  :设置或返回该表格的表头高度

    (7)@property(nonatomic) CGFloatsectionFooterHeight  :设置或返回该表格的表尾高度

    (8)- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section  :返回指定section的表头视图

    (9)- (UITableViewHeaderFooterView *)footerViewForSection:(NSInteger)section  :返回指定section的表尾视图

8.访问cell和section:

    (1)- (__kindofUITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath  :返回指定indexPath的Cell

    (2)- (NSIndexPath *)indexPathForCell:(UITableViewCell *)cell  :返回指定Cell的IndexPath

    (3)- (NSIndexPath *)indexPathForRowAtPoint:(CGPoint)point  :返回指定点的IndexPath,比如发生接触的点

    (4)- (NSArray<NSIndexPath *> *)indexPathsForRowsInRect:(CGRect)rect  :返回指定区域内的IndexPath组成的数组

    (5)@property(nonatomic, readonly) NSArray<__kindof UITableViewCell *> *visibleCells  :返回可见的UITableViewCell组成的数组

    (6)@property(nonatomic, readonly) NSArray<NSIndexPath *> *indexPathsForVisibleRows  :返回可见表格行的IndexPath组成的数组

9.估算元素的高度

    (1)@property(nonatomic) CGFloatestimatedRowHeight  :设置表格行的估算高度以改善性能,默认为0,表示这个没有进行估算

    (2)@property(nonatomic) CGFloatestimatedSectionHeaderHeight  :设置Section表头的估算高度以改善性能,默认为0,表示这个没有进行估算

    (3)@property(nonatomic) CGFloatestimatedSectionFooterHeight  :设置Section表尾的估算高度以改善性能,默认为0,表示这个没有进行估算

10.滚动tableview

    (1)- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
              atScrollPosition:(UITableViewScrollPosition)scrollPosition
                      animated:(BOOL)animated

indexPath

An index path that identifies a row in the table view by its row index and its section index.

NSNotFound is a valid row index for scrolling to a section with zero rows.

scrollPosition

A constant that identifies a relative position in the table view (top, middle, bottom) for row when scrolling concludes. See Table View Scroll Position for descriptions of valid constants.

animated

YES if you want to animate the change in position; NO if it should be immediate.

     解释:滚动到指定的位置

    (2)- (void)scrollToNearestSelectedRowAtScrollPosition:(UITableViewScrollPosition)scrollPosition
                                          animated:(BOOL)animated

scrollPosition

A constant that identifies a relative position in the table view (top, middle, bottom) for the row when scrolling concludes. See Table View Scroll Position for a descriptions of valid constants.

animated

YES if you want to animate the change in position; NO if it should be immediate.

    解释:滚动到最接近指定点的地方

11.管理section

    (1)@property(nonatomic, readonly) NSIndexPath*indexPathForSelectedRow  :返回被选中行的index

    (2)@property(nonatomic, readonly) NSArray<NSIndexPath *> *indexPathsForSelectedRows  :返回多行被选中的index组成的数组

    (3)- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath
                    animated:(BOOL)animated
              scrollPosition:(UITableViewScrollPosition)scrollPosition

indexPath

An index path identifying a row in the table view.

animated

YES if you want to animate the selection and any change in position; NO if the change should be immediate.

scrollPosition

A constant that identifies a relative position in the table view (top, middle, bottom) for the row when scrolling concludes. See Table View Scroll Position for descriptions of valid constants.

    解释:控制该表格选中指定indexPath对应的表格行,最后一个参数控制是否滚动到被选中行的顶端 中间 和底部

    (4)- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath
                      animated:(BOOL)animated

indexPath

An index path identifying a row in the table view.

animated

YES if you want to animate the deselection, and NO if the change should be immediate.

    解释:控制取消选中该表格中指定indexPath对应的表格行

    (5)@property(nonatomic) BOOL allowsSelection  :控制该表格是否允许被选中

    (6)@property(nonatomic) BOOL allowsMultipleSelection  :控制该表格是否允许多选

    (7)@property(nonatomic) BOOL allowsSelectionDuringEditing  :控制表格处于编辑状态时是否允许被选中

    (8)@property(nonatomic) BOOL allowsMultipleSelectionDuringEditing  :控制表格处于编辑状态时是否允许被多选

12.插入,删除,移动rows和sections

    (1)- (void)beginUpdates  :对表格控件执行多个连续的插入,删除和移动操作之前调用这个方法开始更新

    (2)- (void)endUpdates  :对表格控件执行多个连续的插入,删除和移动操作之后调用这个方法结束

    (3)- (void)insertRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
              withRowAnimation:(UITableViewRowAnimation)animation

indexPaths

An array of NSIndexPath objects, each representing a row index and section index that together identify a row in the table view.

animation

A constant that either specifies the kind of animation to perform when inserting the cell or requests no animation. See Table Cell Insertion and Deletion Animation for descriptions of the constants.

    解释:在一个或多个indexPath处插入cell

    (4)- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
              withRowAnimation:(UITableViewRowAnimation)animation

indexPaths

An array of NSIndexPath objects identifying the rows to delete.

animation

A constant that indicates how the deletion is to be animated, for example, fade out or slide out from the bottom. See Table Cell Insertion and Deletion Animation for descriptions of these constants.

    解释:删除一个或多个indexPath处的cell

    (5)- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath
               toIndexPath:(NSIndexPath *)newIndexPath

indexPath

An index path identifying the row to move.

newIndexPath

An index path identifying the row that is the destination of the row at indexPath. The existing row at that location slides up or down to an adjoining index position to make room for it.

    解释:将制定indexPath处的cell移动到另个一indexPath处

    (6)- (void)insertSections:(NSIndexSet *)sections
      withRowAnimation:(UITableViewRowAnimation)animation

sections

An index set that specifies the sections to insert in the table view. If a section already exists at the specified index location, it is moved down one index location.

animation

A constant that indicates how the insertion is to be animated, for example, fade in or slide in from the left. See Table Cell Insertion and Deletion Animation for descriptions of these constants.

    解释:指定的indexSet所包含的一个或多个分区号对应的位置插入分区

    (7)- (void)deleteSections:(NSIndexSet *)sections
      withRowAnimation:(UITableViewRowAnimation)animation

sections

An index set that specifies the sections to delete from the table view. If a section exists after the specified index location, it is moved up one index location.

animation

A constant that either specifies the kind of animation to perform when deleting the section or requests no animation. See Table Cell Insertion and Deletion Animation for descriptions of the constants.

    解释:删除指定indexSet所包含的一个或多个分区号所对应的分区

    (8)- (void)moveSection:(NSInteger)section
          toSection:(NSInteger)newSection

section

The index of the section to move.

newSection

The index in the table view that is the destination of the move for the section. The existing section at that location slides up or down to an adjoining index position to make room for it.

    解释:将指定分区移动到另一个位置

13.管理可编辑的tablecell

    (1)@property(nonatomic, getter=isEditing) BOOL editing  :设置UITableView 是否可以编辑(默认是不可以编辑NO状态)

    (2)- (void)setEditing:(BOOL)editing
          animated:(BOOL)animate

editing

YES to enter editing mode; NO to leave it. The default value is NO.

animate

YES to animate the transition to editing mode; NO to make the transition immediate.

    解释:是否设置为编辑状态

14.重新加载tableview

    (1)- (void)reloadData  :重新载入rows和sections的数据来刷新tableview

    (2)- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
              withRowAnimation:(UITableViewRowAnimation)animation

indexPaths

An array of NSIndexPath objects identifying the rows to reload.

animation

A constant that indicates how the reloading is to be animated, for example, fade out or slide out from the bottom. See Table Cell Insertion and Deletion Animation for descriptions of these constants.

The animation constant affects the direction in which both the old and the new rows slide. For example, if the animation constant is UITableViewRowAnimationRight, the old rows slide out to the right and the new cells slide in from the right.

    解释:重新载入指定位置indexpaths rows的数据,刷新

    (3)- (void)reloadSections:(NSIndexSet *)sections
      withRowAnimation:(UITableViewRowAnimation)animation

sections

An index set identifying the sections to reload.

animation

A constant that indicates how the reloading is to be animated, for example, fade out or slide out from the bottom. See Table Cell Insertion and Deletion Animation for descriptions of these constants.

The animation constant affects the direction in which both the old and the new section rows slide. For example, if the animation constant is UITableViewRowAnimationRight, the old rows slide out to the right and the new cells slide in from the right.

    解释:更新指定sections的数据

    (4)- (void)reloadSectionIndexTitles  :刷新右边的索引条,a-z那和索引条

15.访问tableview的绘制区域

    (1)- (CGRect)rectForSection:(NSInteger)section  :获取分区的大小(包括头视图,所有行和尾视图)

    (2)- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath  :获取指定indexpath 的rows的大小

    (3)- (CGRect)rectForFooterInSection:(NSInteger)section  :获取分区脚视图的大小

    (4)- (CGRect)rectForHeaderInSection:(NSInteger)section  :获取分区头视图的大小

16.管理委托和数据源

    (1)@property(nonatomic, weak) id< UITableViewDataSource> dataSource  :设置tableview的数据源,需要遵守 UITableViewDataSource协议

    (2)@property(nonatomic, weak) id< UITableViewDelegate> delegate  :设置tableview的委托,需要 遵守 UITableViewDelegate协议

17.配置tableview的index

      (1)@property(nonatomic) NSIntegersectionIndexMinimumDisplayRowCount  :设置索引栏最小显示行数,右边的索引条

      (2)@property(nonatomic, strong) UIColor*sectionIndexColor  :设置索引栏字体颜色

      (3)@property(nonatomic, strong) UIColor*sectionIndexBackgroundColor  :设置索引栏背景颜色

      (4)@property(nonatomic, strong) UIColor*sectionIndexTrackingBackgroundColor  :设置索引栏被选中时的颜色

18.管理focus

    (1)@property(nonatomic) BOOL remembersLastFocusedIndexPath  :是否记录最后聚焦的index

19.辅助

    (1)tableview的风格:

    UITableViewStylePlain                // 常规表视图
           UITableViewStyleGrouped                // 偏好样式表视图      

    (2)UITableViewScrollPosition的类型

   UITableViewScrollPositionNone,//同UITableViewScrollPositionTop

    UITableViewScrollPositionTop,//定位完成后,将定位的行显示在tableView的顶部    
    UITableViewScrollPositionMiddle,//定位完成后,将定位的行显示在tableView的中间   
    UITableViewScrollPositionBottom//定位完成后,将定位的行显示在tableView最下面
   (3)UITableViewRowAnimation的类型
    
UITableViewRowAnimationFade,//淡入淡出
    UITableViewRowAnimationRight,//从右滑入
    UITableViewRowAnimationLeft,//从左滑入
    UITableViewRowAnimationTop,//从上滑入
    UITableViewRowAnimationBottom,//从下滑入
    UITableViewRowAnimationNone,  //没有动画
    UITableViewRowAnimationMiddle,          
    UITableViewRowAnimationAutomatic = 100  // 自动选择合适的动画
 
 

UIkit框架之UItableview的更多相关文章

  1. UIKit 框架之UITableView二

    // // ViewController.m // UITableView // // Created by City--Online on 15/5/21. // Copyright (c) 201 ...

  2. UIKit 框架之UITableView一

    UITableView在开发中是用的最多的控件,它包含两个代理:UITableViewDataSource,UITableViewDelegate,先熟悉下API 1.初始化 - (instancet ...

  3. iOS学习32之UIKit框架-可视化编程-XIB

    1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...

  4. iOS开发UIKit框架-可视化编程-XIB

    1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...

  5. UIKit框架使用总结--看看你掌握了多少

    一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...

  6. Swift - 重写UIKit框架类的init初始化方法(以UITabBarController为例)

    原来写了篇文章讲UITabBarController的用法,当时是从UIViewController跳转到UITabBarController页面,代码如下: 1 self.presentViewCo ...

  7. UIKit框架

    在今后的应用程序构建中,会陆续使用各式各样的控件,因此UIKit框架的引入是必不可少的! 一.简介 UIKitk框架提供一系列的Class(类)来建立和管理iPhone OS应用程序的用户界面接口.应 ...

  8. 基础框架Fundation和UIkit框架的定义和使用

    Foundation 框架为所有应用程序提供基本的系统服务 您的应用程序以及 UIKit 和其他框架,都建立在 Foundation 框架的基础结构之上.Foundation 框架提供许多基本的对象类 ...

  9. iOS开发概述UIkit动力学,讲述UIKit的Dynamic特性,UIkit动力学是UIkit框架中模拟真实世界的一些特性。

    转发:http://my.oschina.net/u/1378445/blog/335014 iOS UIKit动力学 Dynamics UIAttachmentBehavior 实现iMessage ...

随机推荐

  1. Redis与Java - 数据结构

    Redis与Java 标签 : Java与NoSQL Redis(REmote DIctionary Server) is an open source (BSD licensed), in-memo ...

  2. [转载]JMeter源码导入Eclipse

    转载自:http://www.cnblogs.com/taoSir/p/5144274.html 由于JMeter纯Java开发,界面也是基于Swing或AWT搞出来的,所以想更深层次的去了解这款工具 ...

  3. jQuery 2.0.3 源码分析 bind/live/delegate/on

    传统的时间处理: 给某一个元素绑定一个点击事件,传入一个回调句柄处理 element.addEventListener('click',doSomething,false); 这样的绑定如果页面上面有 ...

  4. css hack整理:区别FF,IE8,IE7,IE6,SF,CH浏览器

    css hack整理:区别FF,IE8,IE7,IE6,SF,CH浏览器 2013年03月24日 ⁄ CSS ⁄ 共 716字 ⁄ 暂无评论         前端开发最要命的事就是处理浏览器的兼容性问 ...

  5. Servlet视频学习笔记 57-58 (servlet入门和调用过程)

    网易云课堂<30天轻松掌握JavaWeb视频>servlet部分 课时57 servlet开发入门 servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术.S ...

  6. easyui datagrid 学习

    一.清空datagrid所有数据 //得到所有数据行 var item = $('#ylProductListDataGrid').datagrid('getRows'); if (item) { / ...

  7. PL/SQL设置编码方式

    (2012-10-30 21:38:33) 转载▼ 标签: 杂谈 分类: ORACLE 导出sql文件出现乱码问题,百度之后,发现问题是由于PL/SQL客户端和ORACLE的字符编码设置不一致引起的. ...

  8. go——搭建Win7下的Go开发环境

    1.首先需要下载下载go平台安装包 安装程序 下载地址:https://golang.org/dl/ (墙内下载地址http://www.golangtc.com/download),如果是您的系统是 ...

  9. Cassandra——类似levelDB的基于p2p架构的分布式NOSQL数据库

    C: Consistency 一致性 • A: Availability 可用性(指的是快速获取数据) • P: Tolerance of network Partition 分区容忍性(分布式) 1 ...

  10. JavaScript 事件委托的技术原理

    如今的 JavaScript 技术界里最火热的一项技术应该是‘事件委托(event delegation)’了.使用事件委托技术能让你避免对特定的每个节点添加事件监听器:相反,事件监听器是被添加到它们 ...