ios - How To select a table row during a long press in Swift -


i have table has long press gesture recogniser runs code depending on table row selected.

the trouble i'm having have tap row want long press.

how can make table select row long pressing without having tap select first?

the following code works fine me:

add long press gesture recognizer in viewdidload:

// taprecognizer, placed in viewdidload let longpressrecognizer = uilongpressgesturerecognizer(target: self, action: "longpress:") self.view.addgesturerecognizer(longpressrecognizer) 

then method invoke long press looks this:

//called, when long press occurred func longpress(longpressgesturerecognizer: uilongpressgesturerecognizer) {      if longpressgesturerecognizer.state == uigesturerecognizerstate.began {          let touchpoint = longpressgesturerecognizer.locationinview(self.view)         if let indexpath = tableview.indexpathforrowatpoint(touchpoint) {              // code here, row indexpath or whatever want     } } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -