Swift ios didSelectItemAt not called until second click [duplicate]
Swift ios didSelectItemAt not called until second click [duplicate]
This question already has an answer here:
My didSelectItemAt
function is not being executed until I click on a second cell, but it is executing with the data obtained from the first cell clicked. Otherwise everything is working as expected. Help?
didSelectItemAt
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)
let id = boardArray[indexPath.row]
let boardId = id.title
let storyBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let boardViewController = storyBoard.instantiateViewController(withIdentifier: "BoardViewController") as! BoardViewController
boardViewController.name = boardId
self.present(boardViewController, animated: true, completion: nil)
So after I click a second cell, it will display the 'BoardViewController' with the first cell's boardId & such.
Thanks, Jewell
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1 Answer
1
You use didDeselectItemAt
instead of
didDeselectItemAt
func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)
use
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
Good Day =D ........
– Sh_Khan
Sep 16 '18 at 22:31
Thank you!!!! I've been trying everything I can think of since 10am this morning and it was a matter of 2 letters, now it works perfectly. Thanks so much!
– jewell white
Sep 16 '18 at 22:25