TableView CollectionView滚动定位问题

1,139 阅读1分钟

今天build3210上线,重写了点播模块,其它各方面均在预期内,有一个崩溃却有点不知如何处理。 业务中有个逻辑是定位到具体的cell,数据源切换比较频繁,遮阳会造成,cell定位越界问题 code如下

if(indexPath.row < [_delegate numberOfRows] 
  && indexPath.row > -1 
  && [self.collectionView numberOfItemsInSection:0] > indexPath.row) {    
  self.currentSelectIndexPath = indexPath;  
  //TODO:: 当走到这一步时,data数据切换并reloadData,如何处理位置更新呢 ?  
  //TODO:: 或者正在滚动位置,数据源切换了呢 ?    
[self.collectionView 
      scrollToItemAtIndexPath:self.currentSelectIndexPath 
      atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally 
      animated:YES];}

bug率 100 / 40000 = 0.25%