Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Inputbar incorrect position after keyboard appear on iPad presented as formsheet #651

Open
4 tasks done
lingzlu opened this issue Nov 14, 2017 · 0 comments
Open
4 tasks done

Comments

@lingzlu
Copy link

lingzlu commented Nov 14, 2017

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

When present SLKTextViewController on iPad in formsheet style. Input bar position was not computed correctly when keyboard appears. Portrait orientation does not repro the issue.

Reproducible in:

  • This is reproducible in the sample project.
    SlackTextViewController version: 1.9.6
    iOS version(s): iOS 11
    Device(s): iPad Air 2

Steps to reproduce:

  1. Run the sample app "Messenger-iPad-sheet" on iPad
  2. Change device orientation on landscape
  3. Invoke keyboard on the input bar by using one of navigation bar actions.

Expected result:

Input bar should be stick on top of keyboard.

Actual result:

There is an empty gap between the input bar and the keyboard.

Attachments:

image

Investigation

Briefly look at the source code, I suspect the problem is in

- (CGFloat)slk_appropriateKeyboardHeightFromRect:(CGRect)rect
{
CGRect keyboardRect = [self.view convertRect:rect fromView:nil];
CGFloat viewHeight = CGRectGetHeight(self.view.bounds);
CGFloat keyboardMinY = CGRectGetMinY(keyboardRect);
CGFloat keyboardHeight = MAX(0.0, viewHeight - keyboardMinY);
CGFloat bottomMargin = [self slk_appropriateBottomMargin];
// When the keyboard height is zero, we can assume there is no keyboard visible
// In that case, let's see if there are any other views outside of the view hiearchy
// requiring to adjust the text input bottom margin
if (keyboardHeight < bottomMargin) {
keyboardHeight = bottomMargin;
}
return keyboardHeight;
}

When keyboard appeared on landscape, the formsheet is been pushed up. ConvertRect will return the keyboardRect on origin view frame, result in incorrect keyboardHeight been computed. I tried to fix the issue by moving
// Updates the height constraints' constants
self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromNotification:notification];
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];

from slk_willShowOrHideKeyboard to slk_didShowOrHideKeyboard. But then it loses smooth transition on input bar moving up with keyboard. Any suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant