0

I have this class:

class SectionCellRowCollection: UICollectionView, UICollectionViewDataSource, UICollectionViewDelegate {
  
    required init?(coder aDecoder: NSCoder){
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout){
        super.init(frame: frame, collectionViewLayout: layout)
       
        self.initialize()
    }
    
    private func initialize(){        
        self.dataSource = self
        self.delegate = self
        
        self.delaysContentTouches = true
        self.allowsSelection = false
        self.canCancelContentTouches = true
                   
        self.backgroundView = nil
        self.backgroundColor = .clear  
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?){
        print("TOUCH began...")
        
        super.touchesBegan(touches, with: event)
        self.next?.touchesBegan(touches, with: event) //send touch "down"
    }
    
    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesEnded(touches, with: event)
        self.next?.touchesEnded(touches, with: event) //send touch "down"   
    }

    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        print("scrollViewWillBeginDragging")
    }

    func scrollViewDidScroll(_ scrollView: UIScrollView) { 
        print("scroll")
    }

    //init cells etc
}

Problem is that after first show on the collection, when I move to the left/right, touchesBegan is called instead of scrollViewDidScroll or scrollViewWillBeginDragging. When I release touch and touch again, touchesBegan is not called and scrollViewDidScroll works.

I dont know what to look for, since this is hard to debug.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.