0

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)


    }
}
TeoT
  • 1
  • 2
  • try this http://stackoverflow.com/a/34605326/1142743 – Vinodh Nov 01 '16 at 05:24
  • try for deletion http://rshankar.com/uicollectionview-demo-in-swift/ – Vinodh Nov 01 '16 at 05:26
  • Tnx Vinodh, i already used the tutorial, but is little confusing, i tried the first link too, but now i wil change it to UITapGestureRecognizer and keep the old LongPress implementation (i am front-end developer, i will give it to the other programmers after me... to make it all work) – TeoT Nov 01 '16 at 10:39

0 Answers0