user5357137
user5357137

Reputation:

Add a Pan Gesture Recognizer to an UITableView in Swift

How can I add a Pan Gesture Recognizer to an UITableView, without blocking my scrolling feature of my TableView?

This is my code:

@IBOutlet var ScanPanGestureRecognizer: UIPanGestureRecognizer!

@IBAction func ScanPanGestureRecognizer(sender: UIPanGestureRecognizer)
{
    print("TEST")
}

override func viewDidLoad()
{
    ScanTableView.addGestureRecognizer(ScanPanGestureRecognizer)
}

So the code works and I get a lot of prints with "Test" but I'm not able to move (scroll) my TableView any more. I have read some other questions / answers but I couldn't find my issue. I thought that the extension "addGestureRecognizer" only add a gesture and not overwrite the TableView pan gesture... Thanks!

Upvotes: 1

Views: 4096

Answers (1)

dopcn
dopcn

Reputation: 4218

I think whatever you want to do with a pan gesture recognizer on a UITableView you can do it in UITableView's delegate method scrollViewDidScroll: in that method the scrollView.contentOffset will tell you how much the tableView has scrolled

Upvotes: 4

Related Questions