Fixed bug 3305 - Fixed TextInput status when the keyboard was dismissed with the dismiss key on the iPad Diego I was previously unaware that rotating the device to a different orientation when the keyboard is shown causes a keyboardWillHide followed by a keyboardWillShow notification. The previous patch would then mistakenly StopTextInput when rotating. This patch fixes that by checking if the device is rotating before stopping text input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index e6e903e..80bd66f 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -58,6 +58,7 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
#if SDL_IPHONE_KEYBOARD
UITextField *textField;
+ BOOL rotatingOrientation;
#endif
}
@@ -70,6 +71,7 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
#if SDL_IPHONE_KEYBOARD
[self initKeyboard];
+ rotatingOrientation = FALSE;
#endif
#if TARGET_OS_TV
@@ -211,6 +213,29 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
}
}
+/* willRotateToInterfaceOrientation and didRotateFromInterfaceOrientation are deprecated in iOS 8+ in favor of viewWillTransitionToSize */
+#if TARGET_OS_TV || __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000
+- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
+{
+ [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
+ rotatingOrientation = TRUE;
+ [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {}
+ completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
+ rotatingOrientation = FALSE;
+ }];
+}
+#else
+- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
+ [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
+ rotatingOrientation = TRUE;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
+ [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
+ rotatingOrientation = FALSE;
+}
+#endif /* TARGET_OS_TV || __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000 */
+
- (void)deinitKeyboard
{
#if !TARGET_OS_TV
@@ -251,7 +276,8 @@ SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char
- (void)keyboardWillHide:(NSNotification *)notification
{
- SDL_StopTextInput();
+ if (!rotatingOrientation)
+ SDL_StopTextInput();
[self setKeyboardHeight:0];
}