ios - How to click a button lying below UITableView -


say, have button lying under uitableview, how can click button through uitableviewcell not trigger cell click event:

enter image description here

the reason put button behind tableview want see , click button under cell color set clear, , when scroll table, button can covered cell not clear color

i created sample project , got working:

override func viewdidload() {     super.viewdidload()      // additional setup after loading view.      let tap = uitapgesturerecognizer(target: self, action: #selector(tableviewvc.handletap))     tap.numberoftapsrequired = 1     self.view.addgesturerecognizer(tap) }  func handletap(touch: uitapgesturerecognizer) {     let touchpoint = touch.locationinview(self.view)     let ispointinframe = cgrectcontainspoint(button.frame, touchpoint)      print(ispointinframe)      if ispointinframe == true {         print("button pressed")     } } 

to check of button being pressed need use long tap gesture:

override func viewdidload() {     super.viewdidload()      // additional setup after loading view.      let tap = uilongpressgesturerecognizer(target: self, action: #selector(tableviewvc.handletap))     tap.minimumpressduration = 0.01     self.view.addgesturerecognizer(tap) }   func handletap(touch: uilongpressgesturerecognizer) {     let touchpoint = touch.locationinview(self.view)      print(" pressed")     if touch.state == .began {         let ispointinframe = cgrectcontainspoint(button.frame, touchpoint)         print(ispointinframe)          if ispointinframe == true {             print("button pressed")             button.backgroundcolor = uicolor.lightgraycolor()         }     }else if touch.state  == .ended {          button.backgroundcolor = uicolor.whitecolor()     } } 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -