Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save acotilla91/e9ef0b82517cab9a2cda44b57c94154a to your computer and use it in GitHub Desktop.
Save acotilla91/e9ef0b82517cab9a2cda44b57c94154a to your computer and use it in GitHub Desktop.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
activityIndicator.startAnimating()
let person = persons[indexPath.item]
// Clear photos section
self.photos = []
collectionView.reloadSections([photosSection])
// Disable interactions while finding similar images
collectionView.isUserInteractionEnabled = false
// Find photos that match the selected avatar
AzureFaceRecognition.shared.findSimilars(faceId: person.faceId, faceIds: ContentManager.shared.allPhotosFaceIds) { (faceIds) in
self.photos = ContentManager.shared.photos(withFaceIds: faceIds)
self.collectionView.reloadSections([self.photosSection])
self.collectionView.isUserInteractionEnabled = true
self.activityIndicator.stopAnimating()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment