From 5745cfd0d885f436085a0fc1233c8c08cd12aa16 Mon Sep 17 00:00:00 2001 From: Scott Goodson Date: Fri, 18 Dec 2015 21:58:58 -0800 Subject: [PATCH] Enable node detection for tableHeaderView and tableFooterView on ASTableView. Ensure they behave as managed nodes - which prevents them from clearContents-ing their subnodes when the table reloads, as they will be onscreen as long as the table is. --- AsyncDisplayKit/ASTableView.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/AsyncDisplayKit/ASTableView.mm b/AsyncDisplayKit/ASTableView.mm index 2c73367e..ddb68380 100644 --- a/AsyncDisplayKit/ASTableView.mm +++ b/AsyncDisplayKit/ASTableView.mm @@ -532,6 +532,22 @@ static BOOL _isInterceptedSelector(SEL sel) #pragma mark - #pragma mark Intercepted selectors +- (void)setTableHeaderView:(UIView *)tableHeaderView +{ + // Typically the view will be nil before setting it, but reset state if it is being re-hosted. + [self.tableHeaderView.asyncdisplaykit_node exitHierarchyState:ASHierarchyStateRangeManaged]; + [super setTableHeaderView:tableHeaderView]; + [self.tableHeaderView.asyncdisplaykit_node enterHierarchyState:ASHierarchyStateRangeManaged]; +} + +- (void)setTableFooterView:(UIView *)tableFooterView +{ + // Typically the view will be nil before setting it, but reset state if it is being re-hosted. + [self.tableFooterView.asyncdisplaykit_node exitHierarchyState:ASHierarchyStateRangeManaged]; + [super setTableFooterView:tableFooterView]; + [self.tableFooterView.asyncdisplaykit_node enterHierarchyState:ASHierarchyStateRangeManaged]; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { _ASTableViewCell *cell = [self dequeueReusableCellWithIdentifier:kCellReuseIdentifier forIndexPath:indexPath];