From 691749d098b86ebda8ea340ad82695bc8e0ba895 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Fri, 3 Jun 2016 13:24:24 -0700 Subject: [PATCH] Address comments --- AsyncDisplayKit/ASDisplayNode.h | 2 ++ AsyncDisplayKit/ASDisplayNode.mm | 15 +++++++-------- examples/Videos/Sample/ViewController.h | 4 ++-- examples/Videos/Sample/ViewController.m | 17 +++++++++++++---- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index 7c53e93a05..ff63eeee2d 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -15,6 +15,8 @@ #import #import +#define ASDisplayNodeLoggingEnabled 0 + @class ASDisplayNode; /** diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 8cf5137719..355ec6f460 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -48,8 +48,11 @@ NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp = @"AS @end -//#define LOG(...) NSLog(__VA_ARGS__) -#define LOG(...) +#if ASDisplayNodeLoggingEnabled + #define LOG(...) NSLog(__VA_ARGS__) +#else + #define LOG(...) +#endif // Conditionally time these scopes to our debug ivars (only exist in debug/profile builds) #if TIME_DISPLAYNODE_OPS @@ -1094,13 +1097,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) // try to measure the node with the largest size as possible if (self.supernode == nil && !self.supportsRangeManagedInterfaceState && !_flags.isMeasured) { if (CGRectEqualToRect(bounds, CGRectZero)) { - // FIXME: Better log to let developers know that the node was not measured before the layout call and no frame was set - NSLog(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self); + LOG(@"Warning: No size given for node before node was trying to layout itself: %@. Please provide a frame for the node.", self); } else { - ASSizeRange measureSizeRange = ASSizeRangeMake(CGSizeZero, bounds.size); - if ([self shouldMeasureWithSizeRange:measureSizeRange]) { - [self measureWithSizeRange:measureSizeRange]; - } + [self measureWithSizeRange:ASSizeRangeMake(CGSizeZero, bounds.size)]; } } } diff --git a/examples/Videos/Sample/ViewController.h b/examples/Videos/Sample/ViewController.h index 1664a00082..7549a97db6 100644 --- a/examples/Videos/Sample/ViewController.h +++ b/examples/Videos/Sample/ViewController.h @@ -8,8 +8,8 @@ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#import -#import + +#include @interface ViewController : UIViewController diff --git a/examples/Videos/Sample/ViewController.m b/examples/Videos/Sample/ViewController.m index ba1323441d..289d5443d4 100644 --- a/examples/Videos/Sample/ViewController.m +++ b/examples/Videos/Sample/ViewController.m @@ -10,8 +10,7 @@ */ #import "ViewController.h" -#import "ASLayoutSpec.h" -#import "ASStaticLayoutSpec.h" +#import @interface ViewController() @property (nonatomic, strong) ASDisplayNode *rootNode; @@ -22,10 +21,20 @@ #pragma mark - UIViewController -- (void)viewWillAppear:(BOOL)animated +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - [super viewWillAppear:animated]; + self = [super initWithNibName:nil bundle:nil]; + if (self) { + + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Root node for the view controller _rootNode = [ASDisplayNode new]; _rootNode.frame = self.view.bounds;