构建轻量级的Table View注意事项[UIKit]
參考文章来自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]的更多相关文章
- 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 ...
- 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 ...
- iOS学习之Table View的简单使用
Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...
- iphone dev 入门实例1:Use Storyboards to Build Table View
http://www.appcoda.com/use-storyboards-to-build-navigation-controller-and-table-view/ Creating Navig ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- ***iOS学习之Table View的简单使用和DEMO示例(共Plain普通+Grouped分组两种)
Table View简单描述: 在iPhone和其他iOS的很多程序中都会看到Table View的出现,除了一般的表格资料展示之外,设置的属性资料往往也用到Table View,Table View ...
随机推荐
- CentOS5.6下安装Oracle10G软件 【保留报错经验】
CentOS5.6下安装Oracle10G ****************************************************************************** ...
- jquery clone方法
引用自http://www.w3school.com.cn/tiy/t.asp?f=jquery_manipulation_clone <html> <head> <sc ...
- TP-LINK无线路由器WR340G+ 54M支持WDS - 东莞市泰讯电子科技有限公司
TP-LINK无线路由器WR340G+ 54M支持WDS - 东莞市泰讯电子科技有限公司 TP-LINK无线路由器WR340G+ 54M支持WDS 品牌 TP-LINK无线路由器 型号 WR340 ...
- RAC 备份到本地不同设备
- 【Cocos2d-X开发笔记】第一期 Cocos2d-X的环境搭建
作者今天开始正式开始学习Cocos2d-X引擎进行游戏编程,预计两天会更新一期,最后实现ios游戏的appsore上线. (部分内容转载自:http://blog.csdn.net/yan ...
- 齐博软件(地方门户系统) 文件加密破解工具
原文:齐博软件(地方门户系统) 文件加密破解工具 本程序为针对"齐博软件地方门户系统5.0官方原版"的破解工具,一个垃圾系统居然弄出这么恶心的加密方式,有个鸟用!以后见一个破一个! ...
- jQuery简单过滤选择器
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--jQuery选择器详解 根据所获 ...
- RGB與CIELAB色彩空間轉換
原地址:http://cg2010studio.wordpress.com/2012/10/02/rgb與cielab色彩空間轉換/ 之前有研究CIE L*a*b*色彩空間,現在想更進一步探討RGB色 ...
- 自编Ps教程—我的ps图片赞赏
上篇讲述了主要的ps概念和操作,这里不再讲述了,主要的操作学好了,其它的都简单,下面我会把我闲暇时间天马行空的小作品上穿,以供大家闲暇时间或者工作累了的时候赞赏! 以后还会在这里上传哦!喜欢就收藏吧! ...
- Filter基金会
一个.总结 简单的说,Filter的作用就是拦截(Tomcat的)service(Request,Response)方法.拿到Request.Response对象进行处理.然后释放控制.继续自己主动流 ...