【发布时间】:2026-01-23 12:50:01
【问题描述】:
创建分页引擎架构的最佳方法是什么?
在我之前的实现中,我会
- UIViewController
- property UITableView
- with two sections in tableView. One for normal display and other
- for PaginationCell
- and rest of the business logic how to enable and hide indicator View
我们认为每个功能的重复代码过多,因此决定删除重复代码。
我们在UIViewController 上写了一个类别来处理数据分页。现在我们使用scrollViewDidScroll 处理类别内的所有计算,并使用objc_setAssociatedObject 添加指示符页脚视图。
我认为Associated objects 应该被视为一种不得已而为之的方法,而不是寻找问题的解决方案(实际上,类别本身不应该在一开始就位于工具链的顶端)。
所以我的问题是 - 这个新设计是解决这个问题的最佳方案吗?或者您会推荐一些更好的方法吗?
【问题讨论】:
标签: ios uiscrollview pagination categories uivewcontroller