ios - Handle Touch in UiCollectionView - SWIFT? -


i have big uicollectionview occupying major part of screen , there uibutton shows menu. want hide menu when user taps on side of screen becomes unfortunately part of uicollectionview me. tried on other view below code, works well...but not uicollectionview. function not gets called.

override func touchesbegan(touches: set<nsobject>, withevent event: uievent) {                     hidemenu()         self.view.endediting(true)                 } 

what problem? time

or how trigger touchesbegan in uiviewcontroller uicollectionview resides

here project : https://drive.google.com/open?id=0b6dtvd1jbkgbltbhqklewfzesza&authuser=0

while tapping on scrolling controllers (like uiscrollview, uitableview, uicollection etc) not call touchesbegan method. because have own selector method. handle such situation, need create uitapgesture on uicollectionview. while tapping on uicollectionview, selector method called , ever want.

here link guide you. how create double tap gesture on uicollectionview. of can created single tap gesture well.

collection view + double tap gesture

edit : following changes, work fine.

step 1 : declare handletap in swipemenuviewcontroller.

func handletap(sender: uitapgesturerecognizer) {          println("called swipe")      } 

step 2 : create global variable of swipemenuviewcontroller controller. out side of viewdidload()

var vc2 = swipemenuviewcontroller() 

enter image description here

step 3 : declare tapgesture in viewdidload()

var tap = uitapgesturerecognizer(target: vc2, action : "handletap:")         tap.numberoftapsrequired = 1         self.collectionview.addgesturerecognizer(tap) 

output :

called swipe

hope you.


Comments