How do I use UILongPressGestureRecognizer with a UICollectionViewCell in Swift?












21















I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell.



How can I do that in Swift?



I have looked all over for an example of how to do this; can't find one in Swift.










share|improve this question























  • Show us what you've tried.

    – rdelmar
    Mar 24 '15 at 20:02











  • I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

    – webmagnets
    Mar 24 '15 at 20:05
















21















I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell.



How can I do that in Swift?



I have looked all over for an example of how to do this; can't find one in Swift.










share|improve this question























  • Show us what you've tried.

    – rdelmar
    Mar 24 '15 at 20:02











  • I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

    – webmagnets
    Mar 24 '15 at 20:05














21












21








21


13






I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell.



How can I do that in Swift?



I have looked all over for an example of how to do this; can't find one in Swift.










share|improve this question














I would like to figure out how to println the indexPath of a UICollectionViewCell when I long press on a cell.



How can I do that in Swift?



I have looked all over for an example of how to do this; can't find one in Swift.







ios swift uigesturerecognizer uicollectionviewcell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 '15 at 19:55









webmagnetswebmagnets

61132053




61132053













  • Show us what you've tried.

    – rdelmar
    Mar 24 '15 at 20:02











  • I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

    – webmagnets
    Mar 24 '15 at 20:05



















  • Show us what you've tried.

    – rdelmar
    Mar 24 '15 at 20:02











  • I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

    – webmagnets
    Mar 24 '15 at 20:05

















Show us what you've tried.

– rdelmar
Mar 24 '15 at 20:02





Show us what you've tried.

– rdelmar
Mar 24 '15 at 20:02













I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

– webmagnets
Mar 24 '15 at 20:05





I have tried so many things it would be impossible to put all that in here. I have tried using the info at these links: stackoverflow.com/questions/23392485/… - tagwith.com/… - freshconsulting.com/create-drag-and-drop-uitableview-swift TONS of other pages.

– webmagnets
Mar 24 '15 at 20:05












5 Answers
5






active

oldest

votes


















61














First you your view controller need to be UIGestureRecognizerDelegate. Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method



class ViewController: UIViewController, UIGestureRecognizerDelegate {

override func viewDidLoad() {
super.viewDidLoad()

let lpgr = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
lpgr.minimumPressDuration = 0.5
lpgr.delaysTouchesBegan = true
lpgr.delegate = self
self.collectionView.addGestureRecognizer(lpgr)
}


The method to handle long press:



func handleLongPress(gestureReconizer: UILongPressGestureRecognizer) {
if gestureReconizer.state != UIGestureRecognizerState.Ended {
return
}

let p = gestureReconizer.locationInView(self.collectionView)
let indexPath = self.collectionView.indexPathForItemAtPoint(p)

if let index = indexPath {
var cell = self.collectionView.cellForItemAtIndexPath(index)
// do stuff with your cell, for example print the indexPath
println(index.row)
} else {
println("Could not find index path")
}
}


This code is based on the Objective-C version of this answer.






share|improve this answer


























  • Thanks. Perfect!

    – webmagnets
    Mar 24 '15 at 21:45











  • My vertical scroll is not working for my collectionView now :(

    – Qadir Hussain
    Dec 11 '15 at 14:43



















10














ztan answer's converted to swift 3 syntax and minor spelling update:



func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
if gestureRecognizer.state != UIGestureRecognizerState.ended {
return
}

let p = gestureRecognizer.location(in: collectionView)
let indexPath = collectionView.indexPathForItem(at: p)

if let index = indexPath {
var cell = collectionView.cellForItem(at: index)
// do stuff with your cell, for example print the indexPath
print(index.row)
} else {
print("Could not find index path")
}
}





share|improve this answer

































    4














    The method handleLongProgress converted to swift 3 syntax works fine. I just want to add that the initialization of lpgr should be changed to:



    let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gestureReconizer:)))





    share|improve this answer































      3














      One thing I found was that:



      if gestureReconizer.state != UIGestureRecognizerState.Ended {
      return
      }


      doesn't place pin until you release the longpress, which is OK, but I found



      if gestureRecognizer.state == UIGestureRecognizerState.Began { }  


      around the whole function will prevent multiple pin placements while letting the pin appear as soon as the timer delay is satisfied.



      Also, one typo above: Reconizer -> Recognizer






      share|improve this answer


























      • You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

        – James Toomey
        May 31 '16 at 3:18



















      0














      ztan answer's converted to swift 4 syntax and minor spelling update:



      @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
      guard gestureRecognizer.state != .ended else { return }

      let point = gestureRecognizer.location(in: collectionView)

      if let indexPath = collectionView.indexPathForItem(at: point),
      let cell = collectionView.cellForItem(at: indexPath) {
      // do stuff with your cell, for example print the indexPath
      print(indexPath.row)
      } else {
      print("Could not find index path")
      }
      }





      share|improve this answer

























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29241691%2fhow-do-i-use-uilongpressgesturerecognizer-with-a-uicollectionviewcell-in-swift%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        61














        First you your view controller need to be UIGestureRecognizerDelegate. Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method



        class ViewController: UIViewController, UIGestureRecognizerDelegate {

        override func viewDidLoad() {
        super.viewDidLoad()

        let lpgr = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
        lpgr.minimumPressDuration = 0.5
        lpgr.delaysTouchesBegan = true
        lpgr.delegate = self
        self.collectionView.addGestureRecognizer(lpgr)
        }


        The method to handle long press:



        func handleLongPress(gestureReconizer: UILongPressGestureRecognizer) {
        if gestureReconizer.state != UIGestureRecognizerState.Ended {
        return
        }

        let p = gestureReconizer.locationInView(self.collectionView)
        let indexPath = self.collectionView.indexPathForItemAtPoint(p)

        if let index = indexPath {
        var cell = self.collectionView.cellForItemAtIndexPath(index)
        // do stuff with your cell, for example print the indexPath
        println(index.row)
        } else {
        println("Could not find index path")
        }
        }


        This code is based on the Objective-C version of this answer.






        share|improve this answer


























        • Thanks. Perfect!

          – webmagnets
          Mar 24 '15 at 21:45











        • My vertical scroll is not working for my collectionView now :(

          – Qadir Hussain
          Dec 11 '15 at 14:43
















        61














        First you your view controller need to be UIGestureRecognizerDelegate. Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method



        class ViewController: UIViewController, UIGestureRecognizerDelegate {

        override func viewDidLoad() {
        super.viewDidLoad()

        let lpgr = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
        lpgr.minimumPressDuration = 0.5
        lpgr.delaysTouchesBegan = true
        lpgr.delegate = self
        self.collectionView.addGestureRecognizer(lpgr)
        }


        The method to handle long press:



        func handleLongPress(gestureReconizer: UILongPressGestureRecognizer) {
        if gestureReconizer.state != UIGestureRecognizerState.Ended {
        return
        }

        let p = gestureReconizer.locationInView(self.collectionView)
        let indexPath = self.collectionView.indexPathForItemAtPoint(p)

        if let index = indexPath {
        var cell = self.collectionView.cellForItemAtIndexPath(index)
        // do stuff with your cell, for example print the indexPath
        println(index.row)
        } else {
        println("Could not find index path")
        }
        }


        This code is based on the Objective-C version of this answer.






        share|improve this answer


























        • Thanks. Perfect!

          – webmagnets
          Mar 24 '15 at 21:45











        • My vertical scroll is not working for my collectionView now :(

          – Qadir Hussain
          Dec 11 '15 at 14:43














        61












        61








        61







        First you your view controller need to be UIGestureRecognizerDelegate. Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method



        class ViewController: UIViewController, UIGestureRecognizerDelegate {

        override func viewDidLoad() {
        super.viewDidLoad()

        let lpgr = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
        lpgr.minimumPressDuration = 0.5
        lpgr.delaysTouchesBegan = true
        lpgr.delegate = self
        self.collectionView.addGestureRecognizer(lpgr)
        }


        The method to handle long press:



        func handleLongPress(gestureReconizer: UILongPressGestureRecognizer) {
        if gestureReconizer.state != UIGestureRecognizerState.Ended {
        return
        }

        let p = gestureReconizer.locationInView(self.collectionView)
        let indexPath = self.collectionView.indexPathForItemAtPoint(p)

        if let index = indexPath {
        var cell = self.collectionView.cellForItemAtIndexPath(index)
        // do stuff with your cell, for example print the indexPath
        println(index.row)
        } else {
        println("Could not find index path")
        }
        }


        This code is based on the Objective-C version of this answer.






        share|improve this answer















        First you your view controller need to be UIGestureRecognizerDelegate. Then add a UILongPressGestureRecognizer to your collectionView in your viewcontroller's viewDidLoad() method



        class ViewController: UIViewController, UIGestureRecognizerDelegate {

        override func viewDidLoad() {
        super.viewDidLoad()

        let lpgr = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
        lpgr.minimumPressDuration = 0.5
        lpgr.delaysTouchesBegan = true
        lpgr.delegate = self
        self.collectionView.addGestureRecognizer(lpgr)
        }


        The method to handle long press:



        func handleLongPress(gestureReconizer: UILongPressGestureRecognizer) {
        if gestureReconizer.state != UIGestureRecognizerState.Ended {
        return
        }

        let p = gestureReconizer.locationInView(self.collectionView)
        let indexPath = self.collectionView.indexPathForItemAtPoint(p)

        if let index = indexPath {
        var cell = self.collectionView.cellForItemAtIndexPath(index)
        // do stuff with your cell, for example print the indexPath
        println(index.row)
        } else {
        println("Could not find index path")
        }
        }


        This code is based on the Objective-C version of this answer.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 23 '17 at 11:46









        Community

        11




        11










        answered Mar 24 '15 at 21:11









        ztanztan

        6,33021738




        6,33021738













        • Thanks. Perfect!

          – webmagnets
          Mar 24 '15 at 21:45











        • My vertical scroll is not working for my collectionView now :(

          – Qadir Hussain
          Dec 11 '15 at 14:43



















        • Thanks. Perfect!

          – webmagnets
          Mar 24 '15 at 21:45











        • My vertical scroll is not working for my collectionView now :(

          – Qadir Hussain
          Dec 11 '15 at 14:43

















        Thanks. Perfect!

        – webmagnets
        Mar 24 '15 at 21:45





        Thanks. Perfect!

        – webmagnets
        Mar 24 '15 at 21:45













        My vertical scroll is not working for my collectionView now :(

        – Qadir Hussain
        Dec 11 '15 at 14:43





        My vertical scroll is not working for my collectionView now :(

        – Qadir Hussain
        Dec 11 '15 at 14:43













        10














        ztan answer's converted to swift 3 syntax and minor spelling update:



        func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
        if gestureRecognizer.state != UIGestureRecognizerState.ended {
        return
        }

        let p = gestureRecognizer.location(in: collectionView)
        let indexPath = collectionView.indexPathForItem(at: p)

        if let index = indexPath {
        var cell = collectionView.cellForItem(at: index)
        // do stuff with your cell, for example print the indexPath
        print(index.row)
        } else {
        print("Could not find index path")
        }
        }





        share|improve this answer






























          10














          ztan answer's converted to swift 3 syntax and minor spelling update:



          func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
          if gestureRecognizer.state != UIGestureRecognizerState.ended {
          return
          }

          let p = gestureRecognizer.location(in: collectionView)
          let indexPath = collectionView.indexPathForItem(at: p)

          if let index = indexPath {
          var cell = collectionView.cellForItem(at: index)
          // do stuff with your cell, for example print the indexPath
          print(index.row)
          } else {
          print("Could not find index path")
          }
          }





          share|improve this answer




























            10












            10








            10







            ztan answer's converted to swift 3 syntax and minor spelling update:



            func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
            if gestureRecognizer.state != UIGestureRecognizerState.ended {
            return
            }

            let p = gestureRecognizer.location(in: collectionView)
            let indexPath = collectionView.indexPathForItem(at: p)

            if let index = indexPath {
            var cell = collectionView.cellForItem(at: index)
            // do stuff with your cell, for example print the indexPath
            print(index.row)
            } else {
            print("Could not find index path")
            }
            }





            share|improve this answer















            ztan answer's converted to swift 3 syntax and minor spelling update:



            func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
            if gestureRecognizer.state != UIGestureRecognizerState.ended {
            return
            }

            let p = gestureRecognizer.location(in: collectionView)
            let indexPath = collectionView.indexPathForItem(at: p)

            if let index = indexPath {
            var cell = collectionView.cellForItem(at: index)
            // do stuff with your cell, for example print the indexPath
            print(index.row)
            } else {
            print("Could not find index path")
            }
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 13 '18 at 8:14









            Charles Martin

            163112




            163112










            answered Nov 11 '16 at 12:28









            chr0xchr0x

            375716




            375716























                4














                The method handleLongProgress converted to swift 3 syntax works fine. I just want to add that the initialization of lpgr should be changed to:



                let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gestureReconizer:)))





                share|improve this answer




























                  4














                  The method handleLongProgress converted to swift 3 syntax works fine. I just want to add that the initialization of lpgr should be changed to:



                  let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gestureReconizer:)))





                  share|improve this answer


























                    4












                    4








                    4







                    The method handleLongProgress converted to swift 3 syntax works fine. I just want to add that the initialization of lpgr should be changed to:



                    let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gestureReconizer:)))





                    share|improve this answer













                    The method handleLongProgress converted to swift 3 syntax works fine. I just want to add that the initialization of lpgr should be changed to:



                    let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(gestureReconizer:)))






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 17 '17 at 16:37









                    Fernando CardenasFernando Cardenas

                    627612




                    627612























                        3














                        One thing I found was that:



                        if gestureReconizer.state != UIGestureRecognizerState.Ended {
                        return
                        }


                        doesn't place pin until you release the longpress, which is OK, but I found



                        if gestureRecognizer.state == UIGestureRecognizerState.Began { }  


                        around the whole function will prevent multiple pin placements while letting the pin appear as soon as the timer delay is satisfied.



                        Also, one typo above: Reconizer -> Recognizer






                        share|improve this answer


























                        • You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                          – James Toomey
                          May 31 '16 at 3:18
















                        3














                        One thing I found was that:



                        if gestureReconizer.state != UIGestureRecognizerState.Ended {
                        return
                        }


                        doesn't place pin until you release the longpress, which is OK, but I found



                        if gestureRecognizer.state == UIGestureRecognizerState.Began { }  


                        around the whole function will prevent multiple pin placements while letting the pin appear as soon as the timer delay is satisfied.



                        Also, one typo above: Reconizer -> Recognizer






                        share|improve this answer


























                        • You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                          – James Toomey
                          May 31 '16 at 3:18














                        3












                        3








                        3







                        One thing I found was that:



                        if gestureReconizer.state != UIGestureRecognizerState.Ended {
                        return
                        }


                        doesn't place pin until you release the longpress, which is OK, but I found



                        if gestureRecognizer.state == UIGestureRecognizerState.Began { }  


                        around the whole function will prevent multiple pin placements while letting the pin appear as soon as the timer delay is satisfied.



                        Also, one typo above: Reconizer -> Recognizer






                        share|improve this answer















                        One thing I found was that:



                        if gestureReconizer.state != UIGestureRecognizerState.Ended {
                        return
                        }


                        doesn't place pin until you release the longpress, which is OK, but I found



                        if gestureRecognizer.state == UIGestureRecognizerState.Began { }  


                        around the whole function will prevent multiple pin placements while letting the pin appear as soon as the timer delay is satisfied.



                        Also, one typo above: Reconizer -> Recognizer







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 13 '16 at 19:21









                        ayaio

                        57.9k20132185




                        57.9k20132185










                        answered Apr 13 '16 at 19:14









                        DPenDPen

                        32924




                        32924













                        • You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                          – James Toomey
                          May 31 '16 at 3:18



















                        • You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                          – James Toomey
                          May 31 '16 at 3:18

















                        You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                        – James Toomey
                        May 31 '16 at 3:18





                        You are absolutely right, it feels more like the native map to have the pin placed while you're still pressing rather than waiting until the press is released to place the pin. There is full Swift code here: stackoverflow.com/a/29466391/1359088

                        – James Toomey
                        May 31 '16 at 3:18











                        0














                        ztan answer's converted to swift 4 syntax and minor spelling update:



                        @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
                        guard gestureRecognizer.state != .ended else { return }

                        let point = gestureRecognizer.location(in: collectionView)

                        if let indexPath = collectionView.indexPathForItem(at: point),
                        let cell = collectionView.cellForItem(at: indexPath) {
                        // do stuff with your cell, for example print the indexPath
                        print(indexPath.row)
                        } else {
                        print("Could not find index path")
                        }
                        }





                        share|improve this answer






























                          0














                          ztan answer's converted to swift 4 syntax and minor spelling update:



                          @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
                          guard gestureRecognizer.state != .ended else { return }

                          let point = gestureRecognizer.location(in: collectionView)

                          if let indexPath = collectionView.indexPathForItem(at: point),
                          let cell = collectionView.cellForItem(at: indexPath) {
                          // do stuff with your cell, for example print the indexPath
                          print(indexPath.row)
                          } else {
                          print("Could not find index path")
                          }
                          }





                          share|improve this answer




























                            0












                            0








                            0







                            ztan answer's converted to swift 4 syntax and minor spelling update:



                            @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
                            guard gestureRecognizer.state != .ended else { return }

                            let point = gestureRecognizer.location(in: collectionView)

                            if let indexPath = collectionView.indexPathForItem(at: point),
                            let cell = collectionView.cellForItem(at: indexPath) {
                            // do stuff with your cell, for example print the indexPath
                            print(indexPath.row)
                            } else {
                            print("Could not find index path")
                            }
                            }





                            share|improve this answer















                            ztan answer's converted to swift 4 syntax and minor spelling update:



                            @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
                            guard gestureRecognizer.state != .ended else { return }

                            let point = gestureRecognizer.location(in: collectionView)

                            if let indexPath = collectionView.indexPathForItem(at: point),
                            let cell = collectionView.cellForItem(at: indexPath) {
                            // do stuff with your cell, for example print the indexPath
                            print(indexPath.row)
                            } else {
                            print("Could not find index path")
                            }
                            }






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 21 '18 at 15:53

























                            answered Nov 21 '18 at 15:31









                            ArtemArtem

                            687624




                            687624






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29241691%2fhow-do-i-use-uilongpressgesturerecognizer-with-a-uicollectionviewcell-in-swift%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                MongoDB - Not Authorized To Execute Command

                                How to fix TextFormField cause rebuild widget in Flutter

                                in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith