func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! imageUserCell
let coolGesture = UILongPressGestureRecognizer(target: self, action: #selector(detailedPerson.makeItCoolAction(_:)))
coolGesture.minimumPressDuration = 0.5
coolGesture.view?.tag = 4
cell.addGestureRecognizer(coolGesture)
Und dies ist der Funktionscode:
func makeItCoolAction(sender: UIGestureRecognizer){
print(sender.view?.tag)
print("Photo cooled")
}
Die Konsole gibt den gleichen Wert: 0, das ist der Standard ein. Ich muss den indexPath.row-Wert dringend an die makeItCoolAction übergeben, aber ich habe gesehen, dass UIGestureRecognizer keine Tag-Eigenschaft hat, aber die Eigenschaft .view hat sie, wie Sie im Code sehen können.
Ich habe den makeItCoolAction-Absender von UILongPressGestureRecognizer zu UIGestureRecognizer geändert und es weiterhin den 0-Wert drucken.
du bist verdammt recht! Es klappt! –