Xcode- UICollectionView должен выбрать против didSelect
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let selectedItem = collectionView?.indexPathForCell(sender as UICollectionViewCell) {
if segue.identifier == "next" {
var second: SecondViewController = segue.destinationViewController as SecondViewController
second.itemNumber = selectedItem.row
}
}
}
override func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool {
if let cell = collectionView.cellForItemAtIndexPath(indexPath) {
performSegueWithIdentifier("next", sender: cell)
}
return true
}
override func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {
}
Функция shouldSelectItemAtIndexPath
отлично работает так didDeselectItemAtIndexPath
должен быть. didDeselectItemAtIndexPath
работает с некоторыми ячейками, а не с другой случайным образом. Так в чем здесь проблема?
РЕДАКТИРОВАТЬ: Это была опечатка, я использовал didDeselectItemAtIndexPath вместо didSelectItemAtIndexPath