參考文章来自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. find . / -newer oldest_file.txt ! -newer newest_file.txt

    如果希望查找更改时间比某个文件新但比另一个文件旧的所有文件,可以使用-newer选项. 它的一般形式为: $ find . / -newer oldest_file.txt ! -newer newe ...

  2. UVA 116 Unidirectional TSP(dp + 数塔问题)

     Unidirectional TSP  Background Problems that require minimum paths through some domain appear in ma ...

  3. SRM 624 Building Heights DivI 解读

    几乎相同的一标题.欲了解更多请参阅:http://community.topcoder.com/stat?c=problem_statement&pm=13211&rd=15857 思 ...

  4. CodeForces Round #191 (327C) - Magic Five 等比数列求和的快速幂取模

    很久以前做过此类问题..就因为太久了..这题想了很久想不出..卡在推出等比的求和公式,有除法运算,无法快速幂取模... 看到了 http://blog.csdn.net/yangshuolll/art ...

  5. SVN的项目管理

    基于SVN的项目管理——集中与分散   我们在此处不讨论 GIT 比 SVN 好多少,也不讨论 Maven 和 Gradle 哪个好用,基于现有的开发环境,大多数公司还是采用 SVN + Maven ...

  6. 利用PHP SOAP扩展实现简单Web Services

    原文:利用PHP SOAP扩展实现简单Web Services WebServices能干什么? WebServices 可以将应用程序转换为网络应用程序. 通过使用 WebServices,您的应用 ...

  7. POJ 2418 Hardwood Species( AVL-Tree )

    #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> ...

  8. 分类器是如何做检测的?——CascadeClassifier中的detectMultiScale函数解读

    原地址:http://blog.csdn.net/delltdk/article/details/9186875 在进入detectMultiScal函数之前,首先需要对CascadeClassifi ...

  9. 各种oracle10g下载地址(官网网页上好像找不到了)

    Oracle Database 10g Release 2 (10.2.0.1.0) Enterprise/Standard Edition for Microsoft Windows (32-bit ...

  10. 【ArcGIS 10.2新特性】ArcGIS 10.2 for Server常见问题

    1.ArcGIS 10.2有无测试版程序? 10.2没有正式的测试版程序,但是我们计划发布两个早期cuts软件给国际经销商.选中的用户和合作伙伴. 2.微软Azure云的ArcGIS forServe ...