Closed ShouBinCheng closed 5 years ago
在真机情况向调用经常重现。index==-1 报僵尸内存错误在这一句
UICollectionViewLayoutAttributes * cellAttrs = [_collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]];
dispatch_async(dispatch_get_main_queue(), ^{ weakSelf.DataSource = newDataSource;//这里的count值由开始的0到大于0。 [weakSelf.pagerBar reloadData]; });
- (CGRect)cellFrameWithIndex:(NSInteger)index { // ***修复 if (index < 0) { return CGRectZero; } // *** if (index >= _countOfItems) { return CGRectZero; } UICollectionViewLayoutAttributes * cellAttrs = [_collectionView layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]]; if (!cellAttrs) { return CGRectZero; } return cellAttrs.frame; }
在真机情况向调用经常重现。index==-1 报僵尸内存错误在这一句
app 启动时如下去reload 重现bug
修复