UICollectionViewFlowLayout子类有时会在iOS6上崩溃

我想要一个UICollectionViewstream动布局方向是水平的。 我已经实现了方法targetContentOffsetForProposedContentOffset:withScrollingVelocity:当在表格中滚动时总是将视图“捕捉”到集合视图中的单元格。

我已经这样subclassed UICollectionViewFlowLayout(与我的实现方法的代码从这里: targetContentOffsetForProposedContentOffset:withScrollingVelocity没有inheritanceUICollectionViewFlowLayout )

@implementation SnappingFlowLayout -(id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self) { [self customInit]; } return self; } -(void)customInit { // self.itemSize = CGSizeMake(75.0, 75.0); self.minimumInteritemSpacing = 0; self.minimumLineSpacing = 0; self.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); } - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity { CGFloat offsetAdjustment = MAXFLOAT; CGFloat horizontalOffset = proposedContentOffset.x; CGRect targetRect = CGRectMake(proposedContentOffset.x, 0, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); NSArray *array = [super layoutAttributesForElementsInRect:targetRect]; for (UICollectionViewLayoutAttributes *layoutAttributes in array) { CGFloat itemOffset = layoutAttributes.frame.origin.x; if (ABS(itemOffset - horizontalOffset) < ABS(offsetAdjustment)) { offsetAdjustment = itemOffset - horizontalOffset; } } int x = (proposedContentOffset.x + offsetAdjustment) >= 0 ? (proposedContentOffset.x + offsetAdjustment) : 0; return CGPointMake(x, proposedContentOffset.y); } 

当使用这个作为我的UICollectionView的自定义布局时,我有时在集合视图上调用方法时会出现以下错误,但仅在iOS6上

 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewUpdateItem action]: unrecognized selector sent to instance 

这些方法有时会导致错误:

 [self.collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionRight animated:YES]; 

 [self.collectionView deleteItemsAtIndexPaths:indexPaths]; 

我的indexPaths没有什么问题。 他们在iOS7上工作得很好,大部分时间在iOS6上。

有没有什么明显的我在我的子类实现导致这一点错过了?

谢谢。