From 9e8979a12812d18b4ec2ecf3ab907ca88d473c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fre=CC=81de=CC=81ric=20Maquin?= Date: Sat, 5 Oct 2019 18:57:36 +1300 Subject: [PATCH] Partial fix for #218 - division by zero --- .../Helpers/Internal/CoachMarkLayoutHelper.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Instructions/Helpers/Internal/CoachMarkLayoutHelper.swift b/Sources/Instructions/Helpers/Internal/CoachMarkLayoutHelper.swift index d17c5914..e3d3a7e8 100644 --- a/Sources/Instructions/Helpers/Internal/CoachMarkLayoutHelper.swift +++ b/Sources/Instructions/Helpers/Internal/CoachMarkLayoutHelper.swift @@ -222,7 +222,7 @@ class CoachMarkLayoutHelper { forLayoutDirection layoutDirection: UIUserInterfaceLayoutDirection, inFrame frame: CGRect ) -> CoachMarkHorizontalAligment { - if let pointOfInterest = coachMark.pointOfInterest { + if let pointOfInterest = coachMark.pointOfInterest, frame.size.width > 0 { let segmentIndex = Int(ceil(2 * pointOfInterest.x / frame.size.width)) switch (segmentIndex, layoutDirection) { @@ -233,7 +233,12 @@ class CoachMarkLayoutHelper { default: return .centered } } else { - print("[INFO] The point of interest is nil, alignment will fall back to .center.") + if coachMark.pointOfInterest == nil { + print("[INFO] The point of interest is nil, alignment will fall back to .center.") + } else { + print("[WARNING] frame has no width, alignment will fall back to .center.") + } + return .centered } }