From 074cca09061ebc00f9b9669a6e10e5f75ad39708 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 11 May 2017 10:07:37 -0700 Subject: [PATCH] Adjust bottom padding correctly on iOS keyboard hide (flutter/engine#3684) Handle willChangeFrame to handle keyboard show, resize, reposition (split, move floating keyboard) events. Handle willBeHidden events for keyboard dismissal. Fixes incorrect bottom padding introduced in 4103fe7a4006409bbf7e1ad1b06c1f6fbdd12632 due to didChangeFrame notification firing after willBeHidden on keyboard dismissal. --- .../ios/framework/Source/FlutterViewController.mm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 21fa142183..4c075fd35b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -190,8 +190,8 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse { object:nil]; [center addObserver:self - selector:@selector(keyboardFrameDidChange:) - name:UIKeyboardDidShowNotification + selector:@selector(keyboardWillChangeFrame:) + name:UIKeyboardWillChangeFrameNotification object:nil]; [center addObserver:self @@ -199,11 +199,6 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse { name:UIKeyboardWillHideNotification object:nil]; - [center addObserver:self - selector:@selector(keyboardFrameDidChange:) - name:UIKeyboardDidChangeFrameNotification - object:nil]; - [center addObserver:self selector:@selector(onLocaleUpdated:) name:NSCurrentLocaleDidChangeNotification @@ -399,7 +394,7 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(UITouc #pragma mark - Keyboard events -- (void)keyboardFrameDidChange:(NSNotification*)notification { +- (void)keyboardWillChangeFrame:(NSNotification*)notification { NSDictionary* info = [notification userInfo]; CGFloat bottom = CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]);