简体   繁体   中英

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!

我认为您想对UITableView上的平移手势识别器执行任何操作,都可以在UITableView的委托方法scrollViewDidScroll:在该方法中, scrollView.contentOffset将告诉您tableView滚动了多少

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM