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