是不是重用的時(shí)候尉共,CollectionView的contentOffset會(huì)錯(cuò)亂呢傍药?哈哈哈枝恋,現(xiàn)在我就告訴你解決辦法
cell的model里新增屬性:
/**collectionView偏移位置*/
@property (nonatomic, assign) CGFloat collectionViewOffsetX;
在cell.m文件里面模暗,成為collectionView的代理岸晦,用model的偏移屬性記錄偏移的x
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat horizontalOffset = scrollView.contentOffset.x;
self.model.collectionViewOffsetX = horizontalOffset;
}
setModel賦值contentOffset
- (void)setModel:(TVFristListModel *)model {
_model = model;
[_collectionView setContentOffset:CGPointMake(model.collectionViewOffsetX, 0)];
}
搞定~