From 44d4c7003c3c08f2a9827e7604aba07284cc4f86 Mon Sep 17 00:00:00 2001 From: Drew Olbrich Date: Sun, 3 Feb 2019 12:51:42 -0800 Subject: [PATCH] Log a warning only when the size of both axes are undefined --- Source/ScrollingContentViewManager.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/ScrollingContentViewManager.swift b/Source/ScrollingContentViewManager.swift index 21a48aa..14280ee 100644 --- a/Source/ScrollingContentViewManager.swift +++ b/Source/ScrollingContentViewManager.swift @@ -233,11 +233,13 @@ public class ScrollingContentViewManager: KeyboardObservering, ScrollViewBounceC let contentViewSystemLayoutSize = contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) let contentViewIntrinsicContentSize = contentView.intrinsicContentSize - if contentViewSystemLayoutSize.width <= 0 && contentViewIntrinsicContentSize.width == UIView.noIntrinsicMetric { - NSLog("Warning: The content view's width is undefined. You must have an unbroken chain of constraints and views stretching from the content view’s left edge to its right edge or the content view's intrinsic content size must be defined.") - } - if contentViewSystemLayoutSize.height <= 0 && contentViewIntrinsicContentSize.height == UIView.noIntrinsicMetric { - NSLog("Warning: The content view's height is undefined. You must have an unbroken chain of constraints and views stretching from the content view’s top edge to its bottom edge or the content view's intrinsic content size must be defined.") + let widthIsDefined = contentViewSystemLayoutSize.width > 0 || contentViewIntrinsicContentSize.width != UIView.noIntrinsicMetric + let heightIsDefined = contentViewSystemLayoutSize.height > 0 || contentViewIntrinsicContentSize.height != UIView.noIntrinsicMetric + // Warnings are reported only if both the width and height are undefined. When a + // layout is intended to scroll along only one axis, it is convenient to leave the + // size of the other axis undefined. + if !widthIsDefined && !heightIsDefined { + NSLog("Warning: The content view's size is undefined. You must have an unbroken chain of constraints and views stretching across at least one axis of the content view or the content view's intrinsic content size must be defined.") } if contentView.superview == nil {