From 3b91c22fdf23bb72c8a317f9fac8c91a44dc3653 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Thu, 7 Apr 2016 20:08:03 -0700 Subject: [PATCH] Recreate the accessibleElements if accessed --- AsyncDisplayKit/Details/_ASDisplayView.mm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/AsyncDisplayKit/Details/_ASDisplayView.mm b/AsyncDisplayKit/Details/_ASDisplayView.mm index fc2dff6c24..a6700327a7 100644 --- a/AsyncDisplayKit/Details/_ASDisplayView.mm +++ b/AsyncDisplayKit/Details/_ASDisplayView.mm @@ -411,10 +411,6 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode"; - (NSArray *)accessibleElements { - if ( _accessibleElements != nil ) { - return _accessibleElements; - } - _accessibleElements = [[NSMutableArray alloc] init]; ASDisplayNode *selfNode = self.asyncdisplaykit_node; @@ -451,7 +447,7 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode"; for (ASDisplayNode *subnode in selfNode.subnodes) { // Check if this subnode is a UIAccessibilityContainer if (!subnode.isAccessibilityElement && [subnode accessibilityElementCount] > 0) { - // We are good and the view is an UIAccessibilityContainer so add that + // We are good and the view is an UIAccessibilityContainer so add it [_accessibleElements addObject:subnode.view]; } else if (subnode.isAccessibilityElement) { // Create a accessiblity element from the subnode @@ -471,7 +467,11 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode"; - (id)accessibilityElementAtIndex:(NSInteger)index { - UIAccessibilityElement *accessibilityElement = [[self accessibleElements] objectAtIndex:index]; + if (_accessibleElements == nil) { + return nil; + } + + UIAccessibilityElement *accessibilityElement = [_accessibleElements objectAtIndex:index]; ASDisplayNode *accessibilityElementNode = accessibilityElement.asyncdisplaykit_node; if (accessibilityElementNode == nil) { return nil; @@ -497,7 +497,11 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode"; - (NSInteger)indexOfAccessibilityElement:(id)element { - return [self.accessibleElements indexOfObject:element]; + if (_accessibleElements == nil) { + return NSNotFound; + } + + return [_accessibleElements indexOfObject:element]; } @end