Anu*_*han 5 ios uicollectionview swift
我正在使用swift 2.2,我在单元格内部有一个集合视图,我有一个标签.我想在按钮点击的UICollection视图中更改标签文本值,而不使用重新加载整个uiCollection视图.我无法在我的场景中使用collectionView.reloadData().我希望不使用它就可以.只是为了更新collectionview中特定项目中的一个标签.任何帮助?
如果传递IndexPath,则可以访问该单元格,然后可以使用此语法更改标签
let cell = self.collectionView.cellForItem(at: IndexPath) as? yourCollectionViewCellName
cell.label.text = "new text"
Run Code Online (Sandbox Code Playgroud)
你可以这样做:
let indexPath = NSIndexPath(forRow: row, inSection: 0)
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
Run Code Online (Sandbox Code Playgroud)
它不会重新加载您的完整UICollectionView.
| 归档时间: |
|
| 查看次数: |
3006 次 |
| 最近记录: |