简体   繁体   English

Swift 3:CollectionView didSelectItemAt获取选定的单元格标签

[英]Swift 3: CollectionView didSelectItemAt get selected cell label

I've been struggling with this for awhile and can't find it answered elsewhere. 我已经为此苦苦挣扎了一段时间,在其他地方找不到答案。 Basically I need to edit a view inside the selected collection view cell. 基本上,我需要在所选集合视图单元格内编辑视图。 For example once a cell is clicked the label text inside that cell changes. 例如,一旦单击一个单元格,该单元格内的标签文本就会更改。

Here is what i need however it only works on tableviews 这是我需要的,但是它仅适用于tableviews

If I understand it correctly you need to get the selected collection view cell:- 如果我理解正确,则需要获取所选的收藏夹视图单元格:-

if let cell = collectionView.cellForItemAtIndexPath(indexPath) {
 cell.textlabel.text = "yourtext"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM