From 28513efd67799d4c589b100bfef96d416f3b523c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Thu, 17 Jun 2021 19:59:32 +0800 Subject: [PATCH] fix: flow layout cell order --- doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m index 22ee1a7b..832ed877 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlowLayoutNode.m @@ -90,7 +90,12 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { NSNumber *minYOfColumn = @(0); - for (NSNumber *key in self.columnHeightInfo.allKeys) { + NSArray *keys = self.columnHeightInfo.allKeys; + NSArray *sortedKeys = [keys sortedArrayUsingComparator:^NSComparisonResult(NSNumber * obj1, NSNumber *obj2) { + return [obj1 intValue] <= [obj2 intValue] ? -1 : 1; + }]; + + for (NSNumber *key in sortedKeys) { if ([self.columnHeightInfo[key] floatValue] < [self.columnHeightInfo[minYOfColumn] floatValue]) { minYOfColumn = key; }