From 181042368fecc938fc9a938341fb0fd5b0c68aaa Mon Sep 17 00:00:00 2001 From: Jordan Hipwell Date: Sun, 17 Sep 2017 12:21:15 -0600 Subject: [PATCH 1/4] Update bottom margin to accommodate iPhone X home indicator --- Source/SLKTextViewController.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/SLKTextViewController.m b/Source/SLKTextViewController.m index b1eba07b..6b894566 100644 --- a/Source/SLKTextViewController.m +++ b/Source/SLKTextViewController.m @@ -237,6 +237,13 @@ - (void)viewDidLayoutSubviews [super viewDidLayoutSubviews]; } +- (void)viewSafeAreaInsetsDidChange +{ + [super viewSafeAreaInsetsDidChange]; + + [self slk_updateViewConstraints]; +} + #pragma mark - Getters @@ -415,7 +422,7 @@ - (CGFloat)slk_appropriateKeyboardHeightFromRect:(CGRect)rect - (CGFloat)slk_appropriateBottomMargin { - // A bottom margin is required only if the view is extended out of it bounds + // A bottom margin is required if the view is extended out of it bounds if ((self.edgesForExtendedLayout & UIRectEdgeBottom) > 0) { UITabBar *tabBar = self.tabBarController.tabBar; @@ -426,6 +433,11 @@ - (CGFloat)slk_appropriateBottomMargin } } + // A bottom margin is required for iPhone X + if (@available(iOS 11.0, *)) { + return self.view.safeAreaInsets.bottom; + } + return 0.0; } @@ -2227,7 +2239,7 @@ - (void)slk_setupViewConstraints NSDictionary *views = @{@"scrollView": self.scrollViewProxy, @"autoCompletionView": self.autoCompletionView, @"typingIndicatorView": self.typingIndicatorProxyView, - @"textInputbar": self.textInputbar, + @"textInputbar": self.textInputbar }; [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[scrollView(0@750)][typingIndicatorView(0)]-0@999-[textInputbar(0)]|" options:0 metrics:nil views:views]]; From 953ac90b3a0368cb45adef4ea7110cce87d24bb6 Mon Sep 17 00:00:00 2001 From: Ignacio Romero Date: Thu, 26 Oct 2017 14:00:04 -0700 Subject: [PATCH 2/4] Skips the bottom safe area when the textinputbar is hidden --- Source/SLKTextViewController.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/SLKTextViewController.m b/Source/SLKTextViewController.m index ef76ed01..84ac334f 100644 --- a/Source/SLKTextViewController.m +++ b/Source/SLKTextViewController.m @@ -440,7 +440,9 @@ - (CGFloat)slk_appropriateBottomMargin // A bottom margin is required for iPhone X if (@available(iOS 11.0, *)) { - return self.view.safeAreaInsets.bottom; + if (!self.textInputbar.isHidden) { + return self.view.safeAreaInsets.bottom; + } } return 0.0; @@ -894,6 +896,10 @@ - (void)setTextInputbarHidden:(BOOL)hidden animated:(BOOL)animated } _textInputbar.hidden = hidden; + + if (@available(iOS 11.0, *)) { + [self viewSafeAreaInsetsDidChange]; + } __weak typeof(self) weakSelf = self; From fa390ae14bb4890a10c1479d67cec25c8b57651a Mon Sep 17 00:00:00 2001 From: Ignacio Romero Date: Wed, 1 Nov 2017 15:21:22 -0700 Subject: [PATCH 3/4] Reverting #624 to be using UIToolbar again, specially for iPhone X compatibility so the bottom edge of the input bar expands to the bottom of the screen Fixes #619 --- Source/SLKTextInputbar.h | 2 +- Source/SLKTextInputbar.m | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Source/SLKTextInputbar.h b/Source/SLKTextInputbar.h index 74f21604..2ca5e0f6 100644 --- a/Source/SLKTextInputbar.h +++ b/Source/SLKTextInputbar.h @@ -26,7 +26,7 @@ typedef NS_ENUM(NSUInteger, SLKCounterPosition) { NS_ASSUME_NONNULL_BEGIN /** @name A custom tool bar encapsulating messaging controls. */ -@interface SLKTextInputbar : UIView +@interface SLKTextInputbar : UIToolbar /** The centered text input view. The maximum number of lines is configured by default, to best fit each devices dimensions. diff --git a/Source/SLKTextInputbar.m b/Source/SLKTextInputbar.m index 83eaf99d..ca970691 100644 --- a/Source/SLKTextInputbar.m +++ b/Source/SLKTextInputbar.m @@ -19,8 +19,6 @@ @interface SLKTextInputbar () -@property (nonatomic, strong) UIView *hairlineView; - @property (nonatomic, strong) NSLayoutConstraint *textViewBottomMarginC; @property (nonatomic, strong) NSLayoutConstraint *contentViewHC; @property (nonatomic, strong) NSLayoutConstraint *leftButtonWC; @@ -85,7 +83,10 @@ - (void)slk_commonInit self.autoHideRightButton = YES; self.editorContentViewHeight = 38.0; self.contentInset = UIEdgeInsetsMake(5.0, 8.0, 5.0, 8.0); - self.backgroundColor = [UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1.0]; //UIToolbar native bar tint color + + // Since iOS 11, it is required to call -layoutSubviews before adding custom subviews + // so private UIToolbar subviews don't interfere on the touch hierarchy + [self layoutSubviews]; [self addSubview:self.editorContentView]; [self addSubview:self.leftButton]; @@ -93,7 +94,6 @@ - (void)slk_commonInit [self addSubview:self.textView]; [self addSubview:self.charCountLabel]; [self addSubview:self.contentView]; - [self addSubview:self.hairlineView]; [self slk_setupViewConstraints]; [self slk_updateConstraintConstants]; @@ -156,16 +156,6 @@ - (SLKTextView *)textView return _textView; } -- (UIView *)hairlineView -{ - if (!_hairlineView) { - _hairlineView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, [UIScreen mainScreen].bounds.size.width, 0.5)]; - _hairlineView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin; - _hairlineView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3]; - } - return _hairlineView; -} - - (UIView *)contentView { if (!_contentView) { @@ -422,7 +412,7 @@ - (NSUInteger)slk_defaultNumberOfLines - (void)setBackgroundColor:(UIColor *)color { - [super setBackgroundColor:color]; + self.barTintColor = color; self.editorContentView.backgroundColor = color; } From 0a7b7dbecba4c42ea3f1ae2707a8195cde1ed50e Mon Sep 17 00:00:00 2001 From: Ignacio Romero Date: Wed, 1 Nov 2017 15:24:58 -0700 Subject: [PATCH 4/4] [skip-ci] updating changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7bd555..8c4bdfbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ## Version 1.9.6 ##### Hot Fixes & Enhancements: -- Fixed the text input not being interactive on iOS. Making `SLKTextInputbar` a UIView subclass instead of `UIToolbar`. +- Fixed the text input not being interactive on iOS 11 +- Fixed iPhone X issue where the text input bar wouldn't expand to the bottom of the screen, below the "gesture bar". ##### Deprecation: - Deprecated `-shouldProcessTextForAutoCompletion:` in favor of `-shouldProcessTextForAutoCompletion`