From 4103fe7a4006409bbf7e1ad1b06c1f6fbdd12632 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 10 May 2017 16:35:58 -0700 Subject: [PATCH] Update view padding on iOS keyboard frame change (flutter/engine#3681) --- .../ios/framework/Source/FlutterViewController.mm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 6af60c885d..21fa142183 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,7 +190,7 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse { object:nil]; [center addObserver:self - selector:@selector(keyboardWasShown:) + selector:@selector(keyboardFrameDidChange:) name:UIKeyboardDidShowNotification object:nil]; @@ -199,6 +199,11 @@ 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 @@ -394,10 +399,10 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(UITouc #pragma mark - Keyboard events -- (void)keyboardWasShown:(NSNotification*)notification { +- (void)keyboardFrameDidChange:(NSNotification*)notification { NSDictionary* info = [notification userInfo]; CGFloat bottom = - CGRectGetHeight([[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]); + CGRectGetHeight([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]); CGFloat scale = [UIScreen mainScreen].scale; _viewportMetrics.physical_padding_bottom = bottom * scale; [self updateViewportMetrics];