ios - 如何像 UITableViewCell 一样重用 UIView

标签 ios uitableview uiview reusability

我有一个应用程序,其中包含多个相同 UIView 的实例。他们是像 UITableViewCell 一样重用 UIView 的方法吗?类似于:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

最佳答案

我建议您观看 WWDC 的 1042010 session ,名为“使用 ScrollView 设计应用”,其中解释了重用机制 (IIRC)。

也可以看看OHGridView的出处我在其中实现了这项技术:查看 OHGridView.m 中的第二个 layoutSubviews 方法我在 NSMutableSet 中添加未使用的 UIViews 我调用了 recyclePool,然后从这个 中取出一些 UIViews recyclePool 当我需要的时候。

关于ios - 如何像 UITableViewCell 一样重用 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12545097/

相关文章:

ios - 如何从另一个 UIView 访问 UIView title 属性?

ios 快速检测悬停在 uiview 上的时间

ios - 该应用在 Payload : appID, expirationDate, isOpen 中引用了非公共(public)选择器

ios - 子类化 PFUser 时获得正确的类型

ios - 执行函数从另一个类调用performSegueWithIdentifier

ios - 将自定义对象的 NSArray 转换为 Swift 数组

ios - 导航栏在搜索结果表格 View 中消失

ios - 在 xib 文件中查找丢失的 UIView

ios - 当按下 UITableView 行时正确触发 View Controller 打开的问题?

html - iOS Hpple HTML 解析