以前的 UITableView 中的项目出现在新的 UITableView 中

发布于 2025-01-03 19:33:33 字数 84 浏览 1 评论 0原文

我的表格视图出现问题,因为我从导航控制器中弹出一个表格视图,然后推送一个具有类似源数据的新表格视图。不知何故,我看到了旧表格视图中的单元格。有什么想法吗?

I am having an issue with my tableviews as I pop one tableview off my navigation controller and then pushing a new one on with similar data for the source. Somehow I am seeing cells from the old tableview. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗梦空间 2025-01-10 19:33:33

如果这是两个不同的表视图,您可能希望为它们提供不同的重用标识符,例如

对于 FirstTable:
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FirstTableViewCell"];

对于第二个表:
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"SecondTableViewCell"];

if these are two different table views you probably want to give them different reuse identifiers, e.g.

for the FirstTable:
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FirstTableViewCell"];

for the SecondTable:
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"SecondTableViewCell"];

流心雨 2025-01-10 19:33:33

哇,刚刚弄清楚,我正在对单元格进行出队(并使用自定义单元格)以提高响应能力并将引用存储在内存中,当我弹出旧的表格视图时,我将其设置为弹出动画。这以某种方式将单元格保留在内存中足够长的时间,以便当我将新的 UITableView 推入堆栈时,它正在访问取消排队的单元格并呈现它们而不是新数据。因此,如果您打算呈现类似的数据并弹出 UITableView 以将其替换为新数据,请在没有动画的情况下弹出它...
或者如上所述为它们提供一个特定的唯一标识符。 (但我的解决方案只是避免使用动画。

Wow, just figured it out, I was dequeing cells (And using Custom Cells) to increase responsiveness and storing the references in memory, and when I popped the old tableview off I was setting it to animate the pop. This somehow held the cells in memory just long enough so that when I pushed the new UITableView on the stack, it was accessing the de-qued cells and presenting them instead of the new data. So if you plan on presenting similar data and are popping off a UITableView to replace it with the new data, pop it without animation...
Or give them a specifically unique identifier as mentioned above. (But my solution was just to avoid using animation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文