swipe to delete in a UITableView which is embeded in a UIScrollView

后端 未结 5 1544
猫巷女王i
猫巷女王i 2020-12-17 04:04

I\'ve encountered a problem the same as UIScrollview enable delete row by swipe
It is a tableView and another view work as subViews of a scrollView , and I can\'t enab

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-17 04:26

    I know this thread is old, but here is the swift 4 version, working in iOS 11 for me (You would subclass UIScrollView):

    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        if (otherGestureRecognizer.view != nil && otherGestureRecognizer.view!.superview != nil) {
            return otherGestureRecognizer.view!.superview!.isKind(of: UITableView.self)
        }
    
        return false
    }
    
    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
        if (gestureRecognizer.state != .possible) {
            return true
        }
    
        return false
    }
    

提交回复
热议问题