You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/03/27 16:41:38 UTC
[06/11] incubator-weex git commit: * [ios] fix issue that recycler
can not scroll to header
* [ios] fix issue that recycler can not scroll to header
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/df102473
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/df102473
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/df102473
Branch: refs/heads/0.11-dev
Commit: df102473aa7122ba16b619d64d4fe5f84ccfdfce
Parents: 1a37093
Author: \u9690\u98ce <cx...@apache.org>
Authored: Mon Mar 27 15:28:55 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Mon Mar 27 15:28:55 2017 +0800
----------------------------------------------------------------------
.../Component/Recycler/WXRecyclerDataController.h | 2 ++
.../Component/Recycler/WXRecyclerDataController.m | 12 ++++++++++++
2 files changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/df102473/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
index 3b85155..34e8a10 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.h
@@ -31,4 +31,6 @@
- (NSIndexPath *)indexPathForCell:(WXCellComponent *)cell;
+- (NSUInteger)indexForHeader:(WXHeaderComponent *)header;
+
@end
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/df102473/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
index aa5732d..2031837 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerDataController.m
@@ -15,6 +15,7 @@
@property (nonatomic, strong, readwrite) NSArray<WXSectionDataController *> *sections;
@property (nonatomic, strong, readonly) NSMapTable<WXCellComponent *, NSIndexPath*> *cellToIndexPathTable;
+@property (nonatomic, strong, readonly) NSMapTable<WXCellComponent *, NSIndexPath*> *headerToIndexTable;
@end
@@ -25,6 +26,7 @@
if (self = [super init]) {
_sections = [NSArray new];
_cellToIndexPathTable = [NSMapTable weakToStrongObjectsMapTable];
+ _headerToIndexTable = [NSMapTable weakToStrongObjectsMapTable];
}
return self;
@@ -44,6 +46,9 @@
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:idx2 inSection:idx];
[_cellToIndexPathTable setObject:indexPath forKey:obj];
}];
+ if (controller.headerComponent) {
+ [_headerToIndexTable setObject:@(idx) forKey:controller.headerComponent];
+ }
}];
}
@@ -98,6 +103,12 @@
return [_cellToIndexPathTable objectForKey:cell];
}
+- (NSUInteger)indexForHeader:(WXHeaderComponent *)header
+{
+ NSNumber *index = [_headerToIndexTable objectForKey:header];
+ return [index unsignedIntegerValue];
+}
+
#pragma mark - Private
- (WXSectionDataController *)dataControllerForSection:(NSInteger)section
@@ -109,6 +120,7 @@
- (void)cleanup
{
[_cellToIndexPathTable removeAllObjects];
+ [_headerToIndexTable removeAllObjects];
}
@end