XLForm填坑

一直以为cellConfig和cellConfigAtConfigure的作用是相同的,都是用来设置row的属性的,今天发现并非如此。

在row.onChangeBlock中通过cellConfigAtConfigure改变row的文本颜色,发现并不起作用,开始以为是忘记reloadFormRow的缘故,添上问题依旧,后来发现通过cellConfig改变row的属性可以成功,但不知道原因着实心烦,根本没必要存在两个功能相同名字不同的方法,这不符合低冗余的思想,google了一番发现果然还是有区别的

The properties cellConfig and cellConfigAtConfigure are completely different. There are some scenarios in which no matter which method you use you will get the same result.

cellConfigAtConfigure is used right after [[cell alloc] init] is invoked (take a look here), once per UITableViewCell.

cellConfig is used from inside tableView:cellForRowAtIndexpath:method, each time the cell will be shown.

Based on that,cellConfiggives us the ability to override properties that are set up fromupdate methodand configure the cell properties based on context values (for example the value of another row).

cellConfigAtConfiguregive us the ability to set up a property only once at memory allocation time. All the properties that are not set up in the update method can be set up usingcellConfigAtConfigure

翻译如下:

cellConfig和cellConfigAtConfigure的属性是完全不同的。在某些情况下,无论使用哪种方法,都会得到相同的结果。

在调用[[cell alloc] init]之后使用cellConfigAtConfigure(请看这里),每个UITableViewCell一次。

cellConfig从tableView中使用:cellForRowAtIndexpath:方法,每次单元格显示时。

基于此,cellConfig使我们能够覆盖从更新方法设置的属性,并根据上下文值(例如另一行的值)配置单元属性。

cellConfigAtConfigure使我们能够在内存分配时间仅设置一次属性。更新方法中未设置的所有属性都可以使用cellConfigAtConfigure进行设置

大致意思就是,cellConfigAtConfigure只在初始化cell的时候设置属性,而cellConfig不仅在初始化的时候赋值,还在更新cell的时候重新设置属性。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,915评论 18 139
  • 路由介绍 通俗解释:网址 专业解释:每次GET或者POST等请求,在服务端有一个专门的正则配置列表,然后匹配到具体...
    妮儿_smile阅读 418评论 0 1
  • 从小学一年级开始,我一路读到硕士研究生毕业,就这样不间断地读了16年(本科的时候跳了一级),有许多教过我的老师。这...
    伊萨卡阅读 1,728评论 32 33
  • 夏天的铃声来了, 火火的,炙炙的,烈烈的。 响红了万山,激起千层浪。 铃声到处, 天高日烈轻衣透, 独上兰舟觅青荷...
    雪山行阅读 410评论 0 1