From 1c1a8eeead3aebc94e7e0f3d447c7990fd49353b Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 3 Mar 2019 04:24:05 -0800 Subject: [PATCH] Update SDL controller to move stage when keyboard shown. View is moved based on the height of the keyboard. --- src/video/uikit/SDL_uikitviewcontroller.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 49a39b6bc..c60a4b7a4 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -241,7 +241,7 @@ - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures #endif /* - ---- Keyboard related functionality below this line ---- + ---- related functionality below this line ---- */ #if SDL_IPHONE_KEYBOARD @@ -349,6 +349,12 @@ - (void)keyboardWillShow:(NSNotification *)notification kbrect = [self.view convertRect:kbrect fromView:nil]; [self setKeyboardHeight:(int)kbrect.size.height]; + //move stage up + [UIView animateWithDuration:0.3 animations:^{ + CGRect f = self.view.frame; + f.origin.y = -setKeyboardHeight; + self.view.frame = f; + }]; #endif } @@ -358,6 +364,12 @@ - (void)keyboardWillHide:(NSNotification *)notification SDL_StopTextInput(); } [self setKeyboardHeight:0]; + //move stage back down + [UIView animateWithDuration:0.3 animations:^{ + CGRect f = self.view.frame; + f.origin.y = 0.0f; + self.view.frame = f; + }]; } - (void)textFieldTextDidChange:(NSNotification *)notification