iOS:flowlayout fix reused problem
This commit is contained in:
parent
83aab985d3
commit
9531fbffc0
@ -191,7 +191,6 @@ - (UICollectionView *)build {
|
||||
it.dataSource = self;
|
||||
it.showsVerticalScrollIndicator = NO;
|
||||
it.showsHorizontalScrollIndicator = NO;
|
||||
[it registerClass:[DoricFlowLayoutViewCell class] forCellWithReuseIdentifier:@"doricCell"];
|
||||
if (@available(iOS 11, *)) {
|
||||
it.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
@ -335,8 +334,13 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
||||
NSUInteger position = (NSUInteger) indexPath.row;
|
||||
NSDictionary *model = [self itemModelAt:position];
|
||||
NSDictionary *props = model[@"props"];
|
||||
|
||||
DoricFlowLayoutViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"doricCell" forIndexPath:indexPath];
|
||||
NSString *identifier = props[@"identifier"] ?: @"doricCell";
|
||||
if (position >= self.itemCount && self.onLoadMoreFuncId) {
|
||||
identifier = @"doricLoadMoreCell";
|
||||
[self callLoadMore];
|
||||
}
|
||||
[collectionView registerClass:[DoricFlowLayoutViewCell class] forCellWithReuseIdentifier:identifier];
|
||||
DoricFlowLayoutViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
|
||||
if (!cell.viewNode) {
|
||||
DoricFlowLayoutItemNode *itemNode = [[DoricFlowLayoutItemNode alloc] initWithContext:self.doricContext];
|
||||
[itemNode initWithSuperNode:self];
|
||||
@ -352,10 +356,6 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
|
||||
} else {
|
||||
node.view.width = (collectionView.width - (self.columnCount - 1) * self.columnSpace) / self.columnCount;
|
||||
}
|
||||
|
||||
if (position >= self.itemCount && self.onLoadMoreFuncId) {
|
||||
[self callLoadMore];
|
||||
}
|
||||
[node.view.doricLayout apply];
|
||||
[node requestLayout];
|
||||
[self callItem:position size:node.view.frame.size];
|
||||
|
Reference in New Issue
Block a user