Ich setze die Sammlung Ansicht in die Tabellenansicht Zelle und ich machte es auf der Zelle angezeigt, aber wenn ich die Sammlungszelle (um die Farbe oder Druckzellennummer ändern möchten)), die Auswahlfunktion funktioniert nicht, ich muss die Zelle mehrmals antippen, um sie auszuwählen. Warum erkennt die Zelle langsam den ausgewählten Gegenstand? Welcher Code beeinflusst die auszuwählende Zelle?Sammlungsansicht Zelle langsam erkennen ausgewählten Artikel in Swift
Dies ist der Code für wählen Sie die Sammelzelle
override func awakeFromNib() {
super.awakeFromNib()
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
let width = UIScreen.main.bounds.width
layout.scrollDirection = .vertical
layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
layout.itemSize = CGSize(width: width/5, height: width/4)
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
collectionView?.collectionViewLayout = layout
collectionView?.delaysContentTouches = false
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCell", for: indexPath) as! CategoryCollectionViewCell
cell.cateImg.image = imageName[indexPath.row]
cell.cateLabel.text! = nameArray[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? CategoryCollectionViewCell {
cell.cateImg.image = imageName2[indexPath.row]
print("collectionViewCell selected \(indexPath)")
}
}
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? CategoryCollectionViewCell {
cell.cateImg.image = imageName[indexPath.row]
}
}
Projekt zip Link: https://www.dropbox.com/s/y10dgp3q61pi5n1/Finnciti.zip?dl=0
Problem auf AddViewCell.swift
Ich habe genau das gleiche Problem. Ich habe Schwierigkeiten, die Frage zu formulieren. Viel Glück hier. –