I have UIViewController and I have added a UITableView to it in the storyboard, later I added a swipe Up gesture recognizer to the view, but nothing happened.
this is my code
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate {
@IBOutlet weak var tableview: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let swipeRegongnizer = UISwipeGestureRecognizer(target: self, action: #selector(self.handleSwipeUp))
swipeRegongnizer.direction = UISwipeGestureRecognizerDirection.up
swipeRegongnizer.delegate = self
tableview.addGestureRecognizer(swipeRegongnizer)
}
func handleSwipeUp(gesture: UISwipeGestureRecognizer) {
print("swiped up")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = "cell\(indexPath.row)"
return cell
}
}