UICollectionView cell.ViewWithTag returning nil for UILabel

后端 未结 2 1023
予麋鹿
予麋鹿 2021-01-25 17:49

This label seems to return nil, even though I have the reuseIdentifier and tag set properly.

override func collectionView(collectionView: UICollectionView, cell         


        
2条回答
  •  醉酒成梦
    2021-01-25 18:30

    I have just created a sample project with your code and for me it works. Although you shouldn't force unwrap.

    Make sure you have the correct setup in your storyboard:

    Check if your collectionViewCell is setup correctly:

    And set the tag of your label:

    Here is the sample project

提交回复
热议问题