Guest User

Untitled

a guest
Feb 16th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. var alreadyTapped = false
  2. override func viewDidAppear(_ animated: Bool) {
  3. alreadyTapped = false
  4. }
  5. override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  6. if alreadyTapped { return }
  7. alreadyTapped = true
  8. performSegue(withIdentifier: Constants.Segue.DETAIL_VC, sender: collectionView.cellForItem(at: indexPath))
  9. }
  10.  
  11. override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  12. DispatchQueue.main.async {
  13. performSegue(withIdentifier: Constants.Segue.DETAIL_VC, sender: collectionView.cellForItem(at: indexPath))
  14. }
  15. }
  16.  
  17. var didSelectTime = Date()
  18.  
  19. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  20.  
  21. //MARK:- Prevent multiple calls. If elapsed time is less than 1 sec, do nothing
  22. if Date().timeIntervalSince(self.didSelectTime) < 1.0 {
  23. return
  24. }
  25. self.didSelectTime = Date()
  26. .....
  27. }
Add Comment
Please, Sign In to add comment