targetContentOffset(forProposedContentOffset:) in my CustomFlowLayout not called
<p>I am writing a custom UICollectionViewFlowLayout which overrides targetContentOffset(forProposedContentOffset:) in order to provide right contentOffset when user pinch to zoom since I get this problem (wrong contentOffset)</p>
<p><a href="https://stackoverflow.com/questions/13780138/dynamically-setting-layout-on-uicollectionview-causes-inexplicable-contentoffset/25416243#25416243">Dynamically setting layout on UICollectionView causes inexplicable contentOffset change</a></p>
<pre><code>class TimelineCollectionViewFlowLayout: UICollectionViewFlowLayout {
    
    // MARK: - Init
    
    override init() {
        super.init()
        self.minimumLineSpacing = 0
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func prepare() {
        if let collectionView = self.collectionView {
            collectionView.isPagingEnabled = false
            self.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
            self.scrollDirection = .horizontal
        }
    }
    
    override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -&gt; CGPoint {
        print(&quot;hello&quot;)
        return proposedContentOffset
    }
}
</code></pre>
<p>But unfortunately targetContentOffset is not called, do you have an idea why?</p>
<p>Thanks!</p>
<p>Thierry</p>