You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/09/13 03:48:40 UTC
incubator-weex git commit: * [ios] catch out of range exception
Repository: incubator-weex
Updated Branches:
refs/heads/wip-us-0.16-dev [created] d82509d81
* [ios] catch out of range exception
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/d82509d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/d82509d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/d82509d8
Branch: refs/heads/wip-us-0.16-dev
Commit: d82509d81fdb2af8ff1108a4150f4062f461bc64
Parents: ef63a4d
Author: acton393 <zh...@gmail.com>
Authored: Wed Sep 13 11:49:11 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Sep 13 11:49:11 2017 +0800
----------------------------------------------------------------------
.../Component/Recycler/WXMultiColumnLayout.m | 32 +++++++++++++-------
1 file changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/d82509d8/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
index e99e88f..8622ef8 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
@@ -182,19 +182,29 @@ NSString * const kMultiColumnLayoutCell = @"WXMultiColumnLayoutCell";
}
// cells
- for (NSInteger item = 0; item < [self.collectionView numberOfItemsInSection:section]; item++) {
- NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:section];
- CGFloat itemHeight = [self.delegate collectionView:self.collectionView layout:self heightForItemAtIndexPath:indexPath];
- UICollectionViewLayoutAttributes *itemAttributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
- NSUInteger column = [self _minHeightColumnForAllColumns];
- CGFloat x = insets.left + (columnWidth + columnGap) * column;
- CGFloat y = [self.columnsMaxHeights[column] floatValue];
- itemAttributes.frame = CGRectMake(x, y, columnWidth, itemHeight);
- cellAttributes[indexPath] = itemAttributes;
-
- self.columnsMaxHeights[column] = @(CGRectGetMaxY(itemAttributes.frame));
+
+ @try {
+ for (NSInteger item = 0; item < [self.collectionView numberOfItemsInSection:section]; item++) {
+ NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:section];
+ CGFloat itemHeight = [self.delegate collectionView:self.collectionView layout:self heightForItemAtIndexPath:indexPath];
+ UICollectionViewLayoutAttributes *itemAttributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];
+ NSUInteger column = [self _minHeightColumnForAllColumns];
+ CGFloat x = insets.left + (columnWidth + columnGap) * column;
+ if (column >= [self.columnsMaxHeights count]) {
+ return;
+ }
+ CGFloat y = [self.columnsMaxHeights[column] floatValue];
+ itemAttributes.frame = CGRectMake(x, y, columnWidth, itemHeight);
+ cellAttributes[indexPath] = itemAttributes;
+
+ self.columnsMaxHeights[column] = @(CGRectGetMaxY(itemAttributes.frame));
+ }
+ } @catch (NSException *exception) {
+ WXLog(@"%@", exception);
+ } @finally {
}
+
currentHeight = [self _maxHeightForAllColumns];
[self _columnsReachToHeight:currentHeight];
}