參考文章来自objcio站点

一、使用ChildViewController

将Table ViewController作为Child
View Controller加入到其它View Controller中。这种话父Controller能够管理其它View。同一时候你的TableView
Controller也能够继续管理自己的tableview。当然你须要通过一个delegate来使父Controller与子Controller进行通信

二、让Cell能够复用

对于复杂的Cell或者有事多种model对象须要同一个类型的cell表示时。那么我们能够考虑把cell复用。

三、把TableView的DataSource分解到单独的一个类中

UITableView中的DataSource大多都是对数组做的一些操作。能够把数组操作相关的代码移到单独的类中。

能够使用block或者delegate来设置一个cell。

补充

1、在分离时注意要把view层和Controller层的实现细节分开。delegate肯定清除一个view应该显示什么状态,可是它不应该了解怎样改动view的结构或者给某些subviews设置某些属性以获得正确地状态,全部的这些逻辑都应该封装到view的内部,然后对外提供一些简单的API

2、对于一个tableview中有多种类型的cell、datasource。我们就要通过推断cell的类型,然后派发相应的方法。

这点类似策略模式。

3、简单来讲,tableviewcontroller应该在model层和view层扮演一个协调者和解调者的决策,controller不应该关心明显属于view层和model层的任务。能够使用delegate、block、datasource使得tableviewcontroller变得更加小巧。

把业务逻辑和view的逻辑放到更加合适的地方。controller层里里外外的实现细节都封装成简单的API。

构建轻量级的Table View注意事项[UIKit]的更多相关文章

  1. Table View Programming Guide for iOS---(五)---Creating and Configuring a Table View

    Creating and Configuring a Table View Your app must present a table view to users before it can mana ...

  2. Table View Programming Guide for iOS---(三)----Overview of the Table View API

    Overview of the Table View API 表格视图API概述 The table view programming interface includes several UIKit ...

  3. iOS学习之Table View的简单使用

    Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...

  4. iphone dev 入门实例1:Use Storyboards to Build Table View

    http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/ Creating Navig ...

  5. Table View Programming Guide for iOS---(六)---A Closer Look at Table View Cells

    A Closer Look at Table View Cells A table view uses cell objects to draw its visible rows and then c ...

  6. Table View Programming Guide for iOS---(四)---Navigating a Data Hierarchy with Table Views

    Navigating a Data Hierarchy with Table Views 导航数据表视图层次 A common use of table views—and one to which ...

  7. Table View Programming Guide for iOS---(二)----Table View Styles and Accessory Views

    Table View Styles and Accessory Views 表格视图的风格以及辅助视图 Table views come in distinctive styles that are ...

  8. Table View Programming Guide for iOS---(一)---About Table Views in iOS Apps

    About Table Views in iOS Apps Table views are versatile user interface objects frequently found in i ...

  9. ***iOS学习之Table View的简单使用和DEMO示例(共Plain普通+Grouped分组两种)

    Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...

随机推荐

  1. hadoop 磁盘限额配置

    配置方法: 在 hdfs-site.xml 里配置如下参数,注意,那个 value 的值是配置该磁盘保留的DFS不能使用的空间大小,单位是字节. (如果多块硬盘,则表示为每块硬盘保留这么多空间) &l ...

  2. Bootstrap表格的使用

    先定义前端table <table class="table table-striped table-bordered table-hover" id="expan ...

  3. Next-Key Locks

    Next-Key Locks 一个next-key lock 是 一个record lock 在index record 和 一个区间锁 在一个区间在index record之前 InnoDB 执行 ...

  4. 更改EBSserver域名/IP

    more: 341322.1 : How to change the hostname of an Applications Tier using AutoConfig 338003.1 : How  ...

  5. Android OpenGL ES 应用(二) 纹理

    上一篇讲了基础入门 OpenGL (一) ,这一次主要学习OpenGL 纹理基本学习总结 要是做复杂的OpenGL应用程序,一定会用到纹理技术.纹理说白了就是把图片或者视频图像绘制到OpenGL空间中 ...

  6. c# Unicode字符串的解码

    前两天工作中遇到个奇怪的问题,一个unicode字符串(即“\uXXXX”形式)变量,调用HttpUtility.UrlDecode解码过后,还是原样,要么就是乱码状态.无奈之下只能自己写一个解码函数 ...

  7. HTTPS原理(转)

    HTTPS是什么 HTTPS全称为Hypertext Transfer Protocol over Secure Socket Layer,及以安全为目标的HTTP通道,简单说就是HTTP的安全版本. ...

  8. 单点更新线段树 RMQ

    D. Xenia and Bit Operations time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. 【cocos2d-js官方文档】十、log

    api修改情况.左边为新增,右边为原来的. cc.log 不变 cc.warn 新增 cc.error 新增 cc.assert <-- cc.Assert 此次改造有下面几点原因: 加入原来没 ...

  10. linux进程解析--进程的退出及销毁

    一进程的退出: 当一个进程运行完毕或者因为触发系统异常而退出时,最终会调用到内核中的函数do_exit(),在do_exit()函数中会清理一些进程使用的文件描述符,会释放掉进程用户态使用的相关的物理 ...