From d72c26796dba87438d72b980e3c67bb8c90f5c61 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 5 Mar 2019 10:31:20 -0800 Subject: [PATCH] Ensure onboarding views never reclaim layout space from dismissed keyboard. --- .../Registration/OnboardingBaseViewController.swift | 6 ++++++ SignalMessaging/ViewControllers/OWSViewController.h | 4 ++++ SignalMessaging/ViewControllers/OWSViewController.m | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift index a1594d3ec..6d59d0f9e 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingBaseViewController.swift @@ -73,6 +73,12 @@ public class OnboardingBaseViewController: OWSViewController { // MARK: - View Lifecycle + public override func viewDidLoad() { + super.viewDidLoad() + + self.shouldBottomViewReserveSpaceForKeyboard = true + } + public override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) diff --git a/SignalMessaging/ViewControllers/OWSViewController.h b/SignalMessaging/ViewControllers/OWSViewController.h index 6e0ed2c3c..71cb28ad2 100644 --- a/SignalMessaging/ViewControllers/OWSViewController.h +++ b/SignalMessaging/ViewControllers/OWSViewController.h @@ -20,6 +20,10 @@ UIInterfaceOrientationMask DefaultUIInterfaceOrientationMask(void); // BUT adjust its location upward if the keyboard appears. - (void)autoPinViewToBottomOfViewControllerOrKeyboard:(UIView *)view avoidNotch:(BOOL)avoidNotch; +// If YES, the bottom view never "reclaims" layout space if the keyboard is dismissed. +// Defaults to NO. +@property (nonatomic) BOOL shouldBottomViewReserveSpaceForKeyboard; + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/ViewControllers/OWSViewController.m b/SignalMessaging/ViewControllers/OWSViewController.m index 31350bd91..5d756ee94 100644 --- a/SignalMessaging/ViewControllers/OWSViewController.m +++ b/SignalMessaging/ViewControllers/OWSViewController.m @@ -211,7 +211,11 @@ UIInterfaceOrientationMask DefaultUIInterfaceOrientationMask(void) // There's no need to use: [UIView animateWithDuration:...]. // Any layout changes made during these notifications are // automatically animated. - self.bottomLayoutConstraint.constant = offset; + if (self.shouldBottomViewReserveSpaceForKeyboard) { + self.bottomLayoutConstraint.constant = MIN(self.bottomLayoutConstraint.constant, offset); + } else { + self.bottomLayoutConstraint.constant = offset; + } [self.bottomLayoutView.superview layoutIfNeeded]; };