From aa68712497002d46ef5a604bd5e84b268f927049 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 22 Dec 2017 02:59:21 +0300 Subject: Fix keyboard height constraint --- Juick/ViewControllers/NewPostViewController.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Juick/ViewControllers/NewPostViewController.m') diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m index 143dd96..e8c767c 100644 --- a/Juick/ViewControllers/NewPostViewController.m +++ b/Juick/ViewControllers/NewPostViewController.m @@ -26,6 +26,8 @@ - (void)viewDidLoad { [super viewDidLoad]; + self.paddingValue = self.bottomConstraint.constant; + [self.view setBackgroundColor:[ColorScheme mainBackground]]; if (_replyTo != nil) { MessageInputView *inputView = (MessageInputView *) self.inputAccessoryView; inputView.quoteText.text = _replyTo.text; @@ -63,11 +65,9 @@ } -(void) keyboardDidShow:(NSNotification *)sender { - CGRect frame = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - CGRect newFrame = [self.view convertRect:frame fromView:[[UIApplication sharedApplication] delegate].window]; - [self.view layoutIfNeeded]; + CGRect keyboardRect = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; [UIView animateWithDuration:[sender.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] animations:^{ - self.bottomConstraint.constant = newFrame.origin.y - CGRectGetHeight(self.view.frame) + self.paddingValue; + self.bottomConstraint.constant = keyboardRect.size.height - self.view.safeAreaInsets.bottom + self.paddingValue; [self.view layoutIfNeeded]; }]; } @@ -90,5 +90,4 @@ return _inputAccessoryView; } - @end -- cgit v1.2.3