【发布时间】:2013-11-21 17:20:00
【问题描述】:
我正在尝试自动移动我的UICollectionView 中的单元格。移动它的代码:
- (void)scroll {
row += 2;
[UIView animateWithDuration:1.f
delay:0.f
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
[_collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:row inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
}
completion:^(BOOL finished) {
}];
}
我的单元格水平排列成 2 行模式:
|cell||cell||cell|->etc
|cell||cell||cell|->etc
问题是当滚动移动到下一个单元格时,整个 collectionView 移动,前一个单元格消失了。它恰好发生在前一个单元格的一半在屏幕上不可见时。为什么会发生?知道如何解决这个问题吗?
看起来像:(~表示屏幕)
step 1:
~|cell||cell||cell|~
~|cell||cell||cell|~
step 2:
~ell||cell||cell||c~
~ell||cell||cell||c~
step 3:
~ll||cell||cell||ce~
~ll||cell||cell||ce~
step 4:
~ |cell||cell||cel~ --> here first cell disappears even though
~ |cell||cell||cel~ --> there is enough space for it
更重要的是,委托:collectionView:didEndDisplayingCell:forItemAtIndexPath: 在单元格半可见时被调用(因此正好在步骤 3 和 4 之间)
【问题讨论】:
标签: ios iphone objective-c uicollectionview uiviewanimation