UICollectionViewCell 中的标签文本未更新 [英] Label text in UICollectionViewCell not updating

查看:36
本文介绍了UICollectionViewCell 中的标签文本未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 UICollectionViewCell 加载后,在点击 时更改 UICollectionViewCellUILabel 的文本按钮.但标签不会在屏幕上更新.控制台显示标签的 text 属性已更新,但似乎没有使用新文本重新绘制标签.

I'm trying to change the text of a UILabel in a UICollectionViewCell after the UICollectionViewCell has loaded, when tapping a button. But the label doesn't update on the screen. The console shows that the text property of the label is updated, but it seems the label isn't redrawn with the new text.

这是 UICollectionViewCells 的已知问题吗?也许是某种缓存问题?我是否需要重新加载单元格或整个集合视图才能显示更新?

Is this a known problem with UICollectionViewCells? Some kind of caching issue, perhaps? Do I need to reload the cell, or the entire collection view for the update to show?

推荐答案

因为单元格已经加载,所以在重新加载之前单元格不会发生任何变化,因此您可以重新加载整个集合视图[self.collectionView reloadData];

Because the cell is already loaded, no change in cell will happen until it's reloaded, so you can either reload the entire collection view [self.collectionView reloadData];

或者只有一个/多个单元格受到数据更改的影响

Or just one/multiple cell(s) that got affected with that change of data

[self.collectionView reloadItemsAtIndexPaths: indexpathArray];

但请确保在重新加载单元格之前正确更改数据

But make sure that you change the data properly before reloading the cells

这篇关于UICollectionViewCell 中的标签文本未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆