diff --git a/AsyncDisplayKit/ASScrollNode.m b/AsyncDisplayKit/ASScrollNode.m index 3b19d126e2..ade0ee9e5e 100644 --- a/AsyncDisplayKit/ASScrollNode.m +++ b/AsyncDisplayKit/ASScrollNode.m @@ -7,6 +7,19 @@ */ #import "ASScrollNode.h" +#import "_ASDisplayLayer.h" + +@interface ASScrollView : UIScrollView +@end + +@implementation ASScrollView + ++ (Class)layerClass +{ + return [_ASDisplayLayer class]; +} + +@end @implementation ASScrollNode @dynamic view; @@ -14,7 +27,7 @@ - (instancetype)init { return [super initWithViewBlock:^UIView *{ - return [[UIScrollView alloc] init]; + return [[ASScrollView alloc] init]; }]; } diff --git a/AsyncDisplayKit/Details/_ASDisplayLayer.mm b/AsyncDisplayKit/Details/_ASDisplayLayer.mm index 9240c0a42a..1acee3bd58 100644 --- a/AsyncDisplayKit/Details/_ASDisplayLayer.mm +++ b/AsyncDisplayKit/Details/_ASDisplayLayer.mm @@ -93,10 +93,13 @@ [super layoutSublayers]; ASDisplayNode *node = self.asyncdisplaykit_node; - // If our associated node is layer-backed, we cannot rely on the view's -layoutSubviews calling the node's -layout implementation, so do it ourselves. - if (node.isLayerBacked) { - ASDisplayNodeAssertMainThread(); + if (ASDisplayNodeThreadIsMain()) { [node __layout]; + } else { + ASDisplayNodeFailAssert(@"not reached assertion"); + dispatch_async(dispatch_get_main_queue(), ^ { + [node __layout]; + }); } } diff --git a/AsyncDisplayKit/Details/_ASDisplayView.mm b/AsyncDisplayKit/Details/_ASDisplayView.mm index 8a71013fbe..1bebdb9815 100644 --- a/AsyncDisplayKit/Details/_ASDisplayView.mm +++ b/AsyncDisplayKit/Details/_ASDisplayView.mm @@ -122,19 +122,6 @@ } } -- (void)layoutSubviews -{ - if (ASDisplayNodeThreadIsMain()) { - [_node __layout]; - } else { - // FIXME: CRASH This should not be happening because of the way we gate -setNeedsLayout, but it has been seen. - ASDisplayNodeFailAssert(@"not reached assertion"); - dispatch_async(dispatch_get_main_queue(), ^ { - [_node __layout]; - }); - } -} - - (UIViewContentMode)contentMode { return ASDisplayNodeUIContentModeFromCAContentsGravity(self.layer.contentsGravity);