iOS:fix when reuse node,call reset cause property lost

This commit is contained in:
pengfei.zhou 2021-11-03 13:27:00 +08:00 committed by osborn
parent a4ccb10891
commit 02ca1e5081
5 changed files with 14 additions and 3 deletions

View File

@ -371,6 +371,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
[itemNode initWithSuperNode:self]; [itemNode initWithSuperNode:self];
cell.viewNode = itemNode; cell.viewNode = itemNode;
[cell.contentView addSubview:itemNode.view]; [cell.contentView addSubview:itemNode.view];
} else {
[cell.viewNode reset];
} }
DoricFlowLayoutItemNode *node = cell.viewNode; DoricFlowLayoutItemNode *node = cell.viewNode;

View File

@ -165,6 +165,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.backgroundColor = [UIColor clearColor]; cell.backgroundColor = [UIColor clearColor];
listItemNode.view.width = tableView.width; listItemNode.view.width = tableView.width;
[cell.contentView addSubview:listItemNode.view]; [cell.contentView addSubview:listItemNode.view];
} else {
[cell.doricListItemNode reset];
} }
DoricListItemNode *node = cell.doricListItemNode; DoricListItemNode *node = cell.doricListItemNode;
node.viewId = model[@"id"]; node.viewId = model[@"id"];

View File

@ -163,6 +163,8 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
[slideItemNode initWithSuperNode:self]; [slideItemNode initWithSuperNode:self];
cell.doricSlideItemNode = slideItemNode; cell.doricSlideItemNode = slideItemNode;
[cell.contentView addSubview:slideItemNode.view]; [cell.contentView addSubview:slideItemNode.view];
} else {
[cell.doricSlideItemNode reset];
} }
DoricSlideItemNode *node = cell.doricSlideItemNode; DoricSlideItemNode *node = cell.doricSlideItemNode;
node.viewId = model[@"id"]; node.viewId = model[@"id"];

View File

@ -146,4 +146,12 @@ - (NSArray *)getSubNodeViewIds {
return allKeys; return allKeys;
} }
- (void)reset {
[super reset];
for (NSString *viewId in self.subNodes.allKeys) {
[[self subNodeWithViewId:viewId] reset];
}
}
@end @end

View File

@ -103,9 +103,6 @@ - (UIView *)build {
} }
- (void)blend:(NSDictionary *)props { - (void)blend:(NSDictionary *)props {
if (self.superNode.reusable) {
[self reset];
}
for (NSString *key in props) { for (NSString *key in props) {
id value = props[key]; id value = props[key];
if (!value || [value isKindOfClass:[NSNull class]]) { if (!value || [value isKindOfClass:[NSNull class]]) {