2017-09-10 2 views
0

Ich habe 2 benutzerdefinierte Zelle, die singleCell und doubleCell. Ich möchte wissen, welche ausgewählt wurde, wenn die Methode didSelectItemAt trigered wurde.Identifizierer für benutzerdefinierte Zellen

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 
    if singleSelected { 
     print("SINGLE CELL SELECTED) 
    } else { 
     print("DOUBLE CELL SELECTED) 
    } 
} 

Danke.

Antwort

1

Sie können es tun, indem Sie die cellForItem in Ihrer didSelectItemAt Prüffunktion:

if let singleCell = collectionView.cellForItem(at: indexPath) as? SingleCell { 
    // singleCell selected 
} else { 
    // doubleCell selected 
} 
+0

Dank für Ihre Antwort. es funktioniert. – Brkr

+0

@Brkr, großartig! Froh, dass ich Helfen kann. –

Verwandte Themen