苹果的bug?没有调用UICollectionView targetContentOffsetForProposedContentOffset

问题描述:

我在*上看到其他问题,说我需要确保分页设置为关闭。但我已经这样做了,仍然没有被调用。苹果的bug?没有调用UICollectionView targetContentOffsetForProposedContentOffset

有什么我不见了吗?

以下是Github上的示例项目。除了设置集合视图的代码外,其中没有代码。

这里是代码:

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

Apple docs指出,

建议点(以集合视图的内容视图的坐标空间等)的的左上角可见内容。这表示集合视图计算出的最大可能值用于动画或布局更新

换句话说,当您删除或插入单元格到集合视图时会调用它。

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

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

    // do something with contentOffset 

    return contentOffset 
} 

假的集合视图。