dequeueReusableCellWithIdentifier

Objective-C-UI控件学习之dequeueReusableCellWithIdentifier dequeueReusableCellWithIdentifier,从字面上理解是“出列的可重用的cell”,其实简单说就是一个cell池,里面放的就是你之前创建过的cell。使用时要注意: 1。重取出来的cell是有可能已经捆绑过数据或者加过子视图的,所以,如果有必要,要清除数据(比如textlabel的text)和remove掉add过的子视图(使用tag)。 2。这样设计的目的是为了避免频 阅读详情

from@"http://blog.csdn.net/dadalan/archive/2009/04/27/4129729.aspx"

 

 

dequeueReusableCellWithIdentifier:

Returns a reusable table-view cell object located by its identifier.

- (UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier

Parameters
identifier

A string identifying the cell object to be reused. By default, a reusable cell’s identifier is its class name, but you can change it to any arbitrary value.

Return Value

A UITableViewCell object with the associated identifier or nil if no such object exists in the reusable-cell queue.

Discussion

For performance reasons, a table view’s data source should generally reuseUITableViewCell objects when it assigns cells to rows in itstableView:cellForRowAtIndexPath: method. A table view maintains a queue or list ofUITableViewCell objects that the table view’s delegate has marked for reuse. It marks a cell for reuse by assigning it a reuse identifier when it creates it (that is, in theinitWithFrame:reuseIdentifier: method of UITableViewCell). The data source can access specific “template” cell objects in this queue by invoking thedequeueReusableCellWithIdentifier: method. You can access a cell’s reuse identifier through its reuseIdentifier property, which is defined by UITableViewCell.

Availability
  • Available in iPhone OS 2.0 and later.
Related Sample Code
Declared In

 

UITableView.h

 

 

 

dequeueReusableCellWithIdentifier的运行机制猜测

  1. static NSString *CheckMarkCellIdentifier = @"CheckMarkCellIdentifier";
  2.     
  3.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#(NSString *)identifier#>]
  4.     
  5.     if (cell == nil) {
  6.         <#statements#>
  7.     }

书本上讲解的很随意,只是说为了重复使用,和节省资源的内部机制。
看文档介绍的也比较笼统,而代码也只是访问到头文件就终止了,所以才臆测一下实现的机制,还请高手们不论对于错都写点什么。其实我还是很疑惑的。

dequeueReusableCellWithIdentifier消息返回的是UITableViewCell对象,即是说这是一个用来获取UITableViewCell对象的消息,废话。
之所以不说是初始化一个对象,是因为它可能返回nil值,所以才要在下面补充一个如果cell为nil时的处理过程。
那么这个方法是不是可以解释成为,从一个UITableViewCell对象池中获取一个以Identifier参数命名的UITableViewCell对象。
如果在资源紧缺的时候,这个池会自动清理多余的UITableViewCell对象,则可能无法返回对象,但如果资源丰富,则会保存一些UITableViewCell对象,在需要调用的时候迅速的返回,而不用创建.

 

当TABLE一开始加载的时候。。REUSABLEQUEEE中没有任何元素。。当TABLE向下滚动时,滑出TABLEVIEW的CELL被加入到队列中。。下面用到相同的IDENTIFIER的CELL的时候就不用创建,直接 从QUEUE中拿出,修改相应的属性。。避免重复创建大量相同STYLE的CELL

 

 

Redis+Unity 数据库搭建 游戏中需要存放排行榜等数据,而且是实时存放,所以就涉及到数据库的问题。这里找服务器大神了解到可以用Redis来做存储,免费的效率极高。 阅读详情

相关推荐

硬件基础(4):(7)ADC电压采集:软件校准(标定、拟合)

在实际项目中,**软件端校准**可以有效弥补硬件方面(分压电阻误差、放大器失调、参考源误差等)带来的系统性偏差,从而提高 ADC 测量精度。下面是一个常见的**多点实测校准**流程与思路,个人感觉传感器标定的原理也只这样。

FCZlll的博客 6264

dequeueReusableCellWithIdentifier的理解

dequeueReusableCellWithIdentifier,首先我们从字面上理解一下,这个单词翻译一下就是“出列的可重用的cell”,其实简单理解来说就是一个cell池,里面放的就是你之前创建过的cell。        iphone重用机制是苹果为了实现大量数据显示而采用的一种节省内存的机制,比如在UITableView和ScrollView 等地方。为什么要“可重用”?对于我们的

爱喝水的人 2050

【Azure 架构师学习笔记】- Azure Private Endpoint

公有云的其中一个特点是默认允许公网访问, 这就对企业环境带来风险,也是很多年前企业对公有云抵触的其中一个原因,现在这类问题已经很少,因为有了很多技术来确保云上的资源被安全地访问。其中Private endpoint(PE)就起到了很重要的作用。云上的某个资源如VM会创建在特定的网络(VNet/Subnet)上, 而其他如Storage Account , Azure SQL等PaaS服务则没有。如果你需要用VM 来访问这些PaaS资源,VM 就会通过资源的公网IP 来访问。

MVP黄钊吉(發糞塗牆) 1792

dequeueReusableCellWithIdentifier: forIndexPath: 获取cell

在自定义cell的情况下,dequeueReusableCellWithIdentifier:方法获取的cell可能为空,需要代码判断,手动加载cell的xib文件。而dequeueReusableCellWithIdentifier: forIndexPath: 方法获取的cell不会为空。使用步骤为: 1.在tableView初始化时,向tableView注册重用identifier[_tab

xiaolinyeyi的专栏 1525

ADI DSP开发环境(CCES)下的程序烧录问题(以ADSP-SC589为例)

在CCES环境下将程序烧录到flash主要有两种方式。首先在对项目编译产生文件的属性设置为Release。 在编译完成后,找到每个CORE单独生成的DXE文件: 文件通常位于项目目录下每个core的Release文件中。安装SC589评估板的驱动(ADSP-SC5xx_EZ-KIT_Lite-Rel2.0.0.exe)后,在安装目录下可以找到SPI FLASH芯片的驱动程序(sc589_w25q128fv_dpia_Core1.dxe): 把文件copy到CCES 的目录下由于SC58x处理器的特殊性

daijingxin的博客 3735

SAP 凭证分割功能 - 概述&系统配置 - Chapter01/02

为何要进行凭证拆分(分割)?在启用凭证分割之前, 在财务凭证在过账时会自动带出默认的利润中心,这利 润中心一般是从其他对象派生出来的(比如从成本中心、WBS 或资产负债表科 目定义默认的利润中心等),但是某些情况下的财务过账是不会派生出利润中 心的,比如说应收或者应付。如果一笔销售凭证上有两个行项目,10 行对应的成品物料 A 的利润中心为 TPCA-100;公司项目Dr/Cr科目金额利润中心10001Dr应收账款20002Cr库存商品A1500TPCA-1003Cr。

weixin_46525734的博客 3980

UITableViewCell重用机制理解

dequeueResableCellWithIdentifier方法 //对table view的数据进行绑定,即填充cell,自动调用n次 - (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {    UITableViewCell

ljloving的专栏 3495

STM32 HAL库驱动BMP388:从寄存器配置到高精度气压温度采集

本文详细介绍了如何使用STM32 HAL库驱动BMP388气压温度传感器,实现高精度数据采集。内容涵盖从硬件连接到STM32CubeMX配置、关键寄存器解析、驱动源码编写,到核心补偿算法与海拔换算的完整流程,并提供了针对不同应用场景的优化配置与调试技巧,帮助开发者快速构建稳定可靠的测量方案。

weixin_29299807的博客 180

iOS开发Swift-UITableView-tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath)

tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath) 作用:复用cell.可以用标识符从表视图中获得可重用单元格.for: indexPath通过指定单元格位置获得可重用单元格,不需要判断. 用于 dequeue(出队)一个可复用的 cell,用于在 UITableView 或 UICollectionVi...

LYly_B的博客 498

MTK Linux DRM分析(八)- KMS drm_crtc.c

CRTC 在 Linux DRM 子系统中是显示控制的核心,负责时序生成、模式设置和管线的调度。理解其工作原理和 API 对于进行底层图形开发、调试显示问题或 simply understanding how your graphics stack works 都至关重要。

iTom1900 1358

AutoCAD2014与ObjectARX开发环境搭建实战指南

本文提供了一份详细的AutoCAD2014与ObjectARX开发环境搭建实战指南。内容涵盖从AutoCAD2014、Visual Studio 2010及ObjectARX 2014 SDK的版本匹配与环境准备,到Wizard安装、编码问题解决、Visual Studio配置,并最终通过一个完整的绘图命令开发示例,手把手引导开发者创建并加载第一个可运行的ObjectARX插件,为后续深入开发奠定坚实基础。

weixin_28475533的博客 292

dequeueReusableCellWithIdentifier和dequeueReusableCellWithIdentifier:forIndexPath的区别

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 和 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]

ynynynynx4的博客 1468

域自适应的理解与想法(Domain Adaptation)

这幅图是域适应非常有名的一篇论文中的插图,被很多文章转载。 什么是领域自适应? Domain Adaptation是迁移学习中很重要的一部分内容,目的是把分布不同的源域和目标域的数据,映射到一个特征空间中,使其在该空间中的距离尽可能近。于是在特征空间中对source domain训练的目标函数,就可以迁移到target domain上,提高target domain上的准确率。 上面的图主要的思想来源于GAN,上图由三部分组成:特征映射网络 标签分类网络和和域判别网络 其中,source domain的数.

yuanxue18的博客 5986

UITableView中的dequeueReusableCellWithIdentifier使用

Table Data Source Methods中的一个必要实现的方法tableView: cellForRowAtIndexPath: 中经常会包含一段代码: [cpp] view plain copy static NSString *FirstLevelCell = @"FirstLevelCell";       UITableViewC

梦从这里启航,代码改变世界 958

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

dequeueReusableCellWithIdentifier的运行机制

UITableViewCell *cell = nil; if([indexPath row] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; //队列?为什么?n 叫集合 //类型。 cell = [self.tableView dequeueRe

xiaodong liang 9656

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

关于UITableView及dequeueReusableCellWithIdentifier的一些理解

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIndentifier = @"SimpleTableIdentifier"; UITableViewCe

Recording... 3293

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

dequeueReusableCellWithIdentifier vs dequeueReusableCellWithIdentifier : forIndexPath

StackOverFlow链接老外的原文问题链接方法名介绍- (nullable __kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier; // Used by the delegate to acquire an already allocated cell, in lieu of a

Deft_MKJing的博客 854

dequeueReusableCellWithIdentifier 与 dequeueReusableCellWithIdentifier:forIndexPath 区别

参考:http://stackoverflow.com/questions/25826383/when-to-use-dequeuereusablecellwithidentifier-vs-dequeuereusablecellwithidentifi 区别 对于dequeueReusableCellWithIdentifier:forIndexPath,如果没有为复用id注册...

weixin_30594001的博客 207

dequeueReusableCellWithIdentifier:forIndexPath中的断言失败:

So I was making an rss reader for my school and finished the code. 因此,我正在为我的学校准备一个RSS阅读器,并完成了代码。 I

CHCH998的博客 692

iOS dequeueReusableCellWithIdentifier:和dequeueReusableCellWithIdentifier: forIndexPath:的问题

1.dequeueReusableCellWithIdentifier:可以注册cell,也可以用if判断创建cell。对于使用if判断时,如果缓存池中有可重用的cell时,不会执行if判断,如果缓存池没有可重用的cell,执行if中的方法,但是有可能会覆盖上storyboard中的cell样式。2.dequeueReusableCellWithIdentifier:  forIndexPath:...

代码解释生活 1658

iOS dequeueReusableCellWithIdentifier: forIndex: 与dequeueReusableCellWithIdentif比较

(1)dequeueReusableCellWithIdentifier: forIndex: 方法是IOS6.0+版本才出现的,新的重用机制方法;只能在IOS 6.0以上系统才有效; 注意官方SDK说明: newer dequeue method guarantees a cell is returned and resized properly, assuming identifier is

-此夜微凉 1715

关于TableViewCell生成时dequeueReusableCellWithIdentifier的认识

在使用TableView的时候,下面一段代码是必须的,也是最标准的: [cpp] view plaincopyprint? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {       

290
上一篇: 对象相等和一致性
下一篇: Objective-C中init函数实现的相关研究 if ((self = [super init]) != nil)
iphoneing
博客等级 码龄16年 12粉丝 45原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址