I am working on e-Books App, i have UICollectionView with books, when user long press on the UICollectionView (he needs to edit the cells), then on top i show tools (custom "popup" view) and I need to add function so user can select (tap) the books he wants to delete (in every book cell, i have hidden view with image (check icon) inside that i need to show). I need some suggestion, how to make this or maybe links to tutorials.
This is my code (I tried to change color to my cells after long press but didn't work - if someone can help me with this only) :(
@IBAction func handleGesture(_ sender: Any) {
if (sender as AnyObject).state == UIGestureRecognizerState.began
{
// let alertController = UIAlertController(title: nil, message:
// "Long-Press Gesture Detected", preferredStyle: UIAlertControllerStyle.alert)
// alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default,handler: nil))
//
// self.present(alertController, animated: true, completion: nil)
//
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = PhotoStreamView.dequeueReusableCell(withReuseIdentifier: "AnnotatedPhotoCell", for: indexPath) as! AnnotatedPhotoCell
cell.photo = photos[(indexPath as NSIndexPath).item]
cell.backgroundColor = UIColor.red
return cell
}
// Showing Custom View as Tollbar
let rect = CGRect(x: 0, y: 0, width: self.view.frame.width, height: 72)
let EditBooksPopup = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "EditBooksPopup") as! EditBooksPopup
self.addChildViewController(EditBooksPopup)
EditBooksPopup.view.frame = rect
self.view.addSubview(EditBooksPopup.view)
EditBooksPopup.didMove(toParentViewController: self)
}
}