Created
September 10, 2015 20:45
Disabling Focus in UICollectionView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func collectionView(collectionView: UICollectionView, shouldUpdateFocusInContext context: UICollectionViewFocusUpdateContext) -> Bool { | |
guard let indexPaths = collectionView.indexPathsForSelectedItems() else { return true } | |
return indexPaths.isEmpty | |
} | |
func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool { | |
if let indexPath = collectionView.indexPathsForSelectedItems()?.first { | |
collectionView.deselectItemAtIndexPath(indexPath, animated: true) | |
return false | |
} | |
else { | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment