gpt4 book ai didi

iphone - iOS — UITableViewCell reuseIdentifiers 是全局的吗?

转载 作者:可可西里 更新时间:2023-11-01 03:07:15 25 4
gpt4 key购买 nike

表格 View 单元格的重用标识符的范围是什么——它们是在一个表格 View 实例中共享,还是在所有使用相同重用标识符的表格 View 中共享?

例如,我有一个 FooTableViewController 和一个 BarTableViewController,它们都有一个 tableView,并且都在 tableView:cellForRowAtIndexPath 中使用 @"Cell"标识符,但单元格属性/样式不同。问题是 - 这些单元格是否会跨 TableView 重用?

最佳答案

它们从不在实例之间共享。

A UITableView object maintains a queue (or list) of the currently reusable cells, each with its own reuse identifier, and makes them available to the delegate in the dequeueReusableCellWithIdentifier: method.

(来自 [UITableViewCell reuseIdentifier] 文档)

强调“UITableView 对象”。

但是,您应该使您的单元格标识符更具描述性。您使用的每种细胞类型都有不同的标识符。您的代码将更具可读性。

关于iphone - iOS — UITableViewCell reuseIdentifiers 是全局的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9838570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com