summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs b/Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs
new file mode 100644
index 00000000..4ebb75d7
--- /dev/null
+++ b/Xamarin.Forms.Platform.iOS/Renderers/KeyboardObserver.cs
@@ -0,0 +1,37 @@
+using System;
+#if __UNIFIED__
+using UIKit;
+
+#else
+using MonoTouch.UIKit;
+#endif
+
+namespace Xamarin.Forms.Platform.iOS
+{
+ internal static class KeyboardObserver
+ {
+ static KeyboardObserver()
+ {
+ UIKeyboard.Notifications.ObserveWillShow(OnKeyboardShown);
+ UIKeyboard.Notifications.ObserveWillHide(OnKeyboardHidden);
+ }
+
+ public static event EventHandler<UIKeyboardEventArgs> KeyboardWillHide;
+
+ public static event EventHandler<UIKeyboardEventArgs> KeyboardWillShow;
+
+ static void OnKeyboardHidden(object sender, UIKeyboardEventArgs args)
+ {
+ var handler = KeyboardWillHide;
+ if (handler != null)
+ handler(sender, args);
+ }
+
+ static void OnKeyboardShown(object sender, UIKeyboardEventArgs args)
+ {
+ var handler = KeyboardWillShow;
+ if (handler != null)
+ handler(sender, args);
+ }
+ }
+} \ No newline at end of file