-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implements an alternative technique for dragging the keyboard on iOS 9 #355
Conversation
} | ||
} | ||
|
||
- (UIWindow *)keyboardWindow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crazy idea. Have you tried grabbing the keyWindow from the UIApplication after the keyboard notification event has fired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Unfortunately, the key window doesn't change. It's always the app window.
The keyboard window should always be above any other window from the view hiearchy, since it needs to overlap any piece of UI. But still, this could eventually break on future iOS releases. It is not reliable, but so far, the best way to access its view "legally".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Why not create an input accessory view of the same height as the text view, and get its frame and move the actual text view? |
We used to do that, some time ago. We moved away from that approach since it wasn't satisfactory enough (dragging lags, UI issues, firing more keyboard notifications than expected, etc.). On iOS 7 and 8, it seemed more reliable to be able to drag the keyboard view guaranteeing the sticky effect of the text input. We never anticipated that huge change on iOS 9. Moving back to the old approach would mean a huge refactor. |
@dzenbot how do you think the other people (FB, Insta etc.) do it? |
I sincerely have no clue. |
Why don't you use |
@iosdeveloper please see #361 (comment) |
Closing/Reopening to run tests again. |
f49bf06
to
6f6227a
Compare
6f6227a
to
b7e7745
Compare
…d up on iOS 9, without using any private APIs
…th the mockup. Reproducible by scrolling up very quickly, while the keyboard is visible. This is a temporary fix, since it comes with a side effect too.
… keyboard snapshot/swap whenever the finger touches the input bar (much more reliable)
b7e7745
to
f3f31a7
Compare
…and tweaks the internals to work in other edge cases.
…This helps avoiding a lag when dragging the text input bar while the keyboard placeholder isn't yet shown. Still needs tweaks.
I Might be a little late but, this can be done by setting an invisible view as an InputAccessoryView of the textView, and then using KVO to observe frame and center changes. The only challenge I had with this solution was handling and calculating offsets when running in a modal form-sheet in an iPad landscape mode. I believe SlackTextViewController has this issue as well |
That is exactly what we used to do before. It's a well known and clean technique. On iOS 9, this call will never work:
|
@dzenbot Not quite sure what the issue is. I'm currently using this technique in production with no issues on iOS9. I just tested and verified (iOS 9.2.1) that the one thing I noticed is that only
|
What is |
it returns |
I will give it a try to https://github.com/aryaxt/TextInputBar/ but it might just not apply much for this project, since we don't layout the textInput as a text input accessory view any more. Switching back will mean a huge refactor. |
@dzenbot 👍 |
@dzenbot Man I feel your pain here haha. Did you every try using the accessoryView and overriding addConstraint: to capture and modify the height constraint? If so any issues? I'm using the auto-created height constraint to update the height of the accessoryView to allow for the interactive dismiss to still work. Since that internal constraint is not animatable, I animate the content to the new height before setting the internal constraint. Check out my project here https://github.com/ashare80/ASTextInputAccessoryView |
That looks very interesting! Will have a look real soon. |
@dzenbot thanks for this solution! Thanks! |
We will eventually revisit this solution with a different approach after all. |
Has this issue been abandoned? How do we enable this behavior? |
@dzenbot Is this still a problem? or what do you use in slack today to achieve keyboard dragging? |
@aryaxt's solution worked for me! |
Super interested in the different approach, keyboard panning to dismiss is sorely missed. |
|
Because the keyboard is on its own view hierarchy since iOS 9, we needed to lookup for its view so we could move the keyboard view following the text input using a panning gesture, using private APIs. We no longer use private APIs, but we needed this feature back.
This is an alternative technique, working in the following way:
Began
, we take a snapshot of the keyboard window and add it as a subview of the textInputbar, just below, at the same position the keyboard is.Possible
,Cancelled
,Ended
orFailed
, we remove the keyboard mockup and unhide the keyboard window, going back to the original layout.This works great on iPhone and iPad. It is not needed on iOS 8 and 7, since we are able to access the keyboard view like we use to, without any private API usage.
Here's the result:
