forkingdog / UITableView-FDTemplateLayoutCell

Template auto layout cell for automatically UITableViewCell height calculating
MIT License
9.93k stars 2.01k forks source link

一些开发上的实际问题 #325

Open mddios opened 7 years ago

mddios commented 7 years ago

今天看了源码,有几个问题请教:key缓存的方式与一般的model直接赋值,实现了解耦。但也使的cell赋值大于一次(高度缓存没有命中),对一些统计逻辑需要另做处理

    // Manually calls to ensure consistent behavior with actual cells. (that are displayed on screen)
    [templateLayoutCell prepareForReuse];

    // Customize and provide content for our template cell.
    if (configuration) {
        configuration(templateLayoutCell);
    }

需要程序员定期的删除高度缓存invalidateAllHeightCache,不像indexpath一样通过hook可以自动的实现高度缓存的清除。不然key方式的高度缓存一直在字典里面累加(当然这个,程序员可以通过key值解决)

UITableView (FDIndexPathHeightCacheInvalidation)里面的钩子函数,保证了indexpath刷新时能够更新高度缓存,但是项目里面其他的UITableView实现没有用本框架(比如一些简单的tableview),也被迫调用钩子函数。是否可以通过一个开关,或者在UITableView的子类里面实现这些钩子函数,从而不至于影响全局

源码没有使用runloop空闲来预缓存,还是有点遗憾的:)。不过iOS8之后,好像也没有预缓存的必要了


写完之后感觉我是不是要求的太多,哈哈,感谢感谢!

mddios commented 7 years ago

key方式的缓存 ,可以使用NSCache的方式来实现: