2016-04-23 83 views
0

我在StackOverflow上看到其他問題,說我需要確保分頁設置爲關閉。但我已經這樣做了,仍然沒有被調用。蘋果的bug?沒有調用UICollectionView targetContentOffsetForProposedContentOffset

有什麼我不見了嗎?

以下是Github上的示例項目。除了設置集合視圖的代碼外,其中沒有代碼。

這裏是代碼:

func collectionView(collectionView: UICollectionView, targetContentOffsetForProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint { 
    return proposedContentOffset 
} 

回答

3

Apple docs指出,

建議點(以集合視圖的內容視圖的座標空間等)的的左上角可見內容。這表示集合視圖計算出的最大可能值用於動畫或佈局更新

換句話說,當您刪除或插入單元格到集合視圖時會調用它。

4

您可能會isPagingEnabled集想着targetContentOffset(forProposedContentOffset:withScrollingVelocity:)

override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 
    var contentOffset = proposedContentOffset 

    // do something with contentOffset 

    return contentOffset 
} 

假的集合視圖。

相關問題