2016-11-08 1 views
1

と呼ばれていない)targetContentOffset(forProposedContentOffset :)私CustomFlowLayoutに私はこの問題(間違ったcontentOffsetを取得するので、私はtargetContentOffsetをオーバーライドするカスタムUICollectionViewFlowLayout(forProposedContentOffset :)ユーザーのピンチをズームする際、右contentOffsetを提供するためにを書いています

Dynamically setting layout on UICollectionView causes inexplicable contentOffset change

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) -> CGPoint { 
     print("hello") 
     return proposedContentOffset 
    } 
} 

しかし、残念ながらtargetContentOffsetが呼び出されていない、あなたのアイデア理由がありますか?

ありがとうございます!

ティエリ

答えて

3

override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint 
てみてください
関連する問題