iOS Guides | Samples

MonoTouch.UIKit.UIKeyboard Class

The iPhone virtual keyboard.

See Also: UIKeyboard

Syntax

[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public static class UIKeyboard

Remarks

The UIKeyboard class contains constants and methods to track the visibility of the iPhone virtual keyboard. iOS posts a number of notifications when the keyboard is shown, hidden or moved in the screen.

The preferred way of receiving UIKeyboard notification is to use the UIKeyboard+Notifications class, which provides a strongly-typed set of APIs to track the changes to the keyboard state and provides strongly-typed accessors to the various parameters of the keyboard changes.

C# Example

//
// Lambda style
//

// listening
notification = UIKeyboard.Notifications.ObserveDidChangeFrame ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("FrameBegin", args.FrameBegin);
    Console.WriteLine ("FrameEnd", args.FrameEnd);
    Console.WriteLine ("AnimationDuration", args.AnimationDuration);
    Console.WriteLine ("AnimationCurve", args.AnimationCurve);
});

// To stop listening:
notification.Dispose ();

//
// Method style
//
NSObject notification;
void Callback (object sender, MonoTouch.UIKit.UIKeyboardEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("FrameBegin", args.FrameBegin);
    Console.WriteLine ("FrameEnd", args.FrameEnd);
    Console.WriteLine ("AnimationDuration", args.AnimationDuration);
    Console.WriteLine ("AnimationCurve", args.AnimationCurve);
}

void Setup ()
{
    notification = UIKeyboard.Notifications.ObserveDidChangeFrame (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIKeyboard are listed below.

See Also: Object

Public Properties

[read-only]
static
AnimationCurveUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardAnimationCurveUserInfoKey
[read-only]
static
AnimationDurationUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardAnimationDurationUserInfoKey
[read-only]
static
BoundsUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardBoundsUserInfoKey
[read-only]
static
CenterBeginUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardCenterBeginUserInfoKey
[read-only]
static
CenterEndUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardCenterEndUserInfoKey
[read-only]
static
DidChangeFrameNotificationNSString. Notification constant for DidChangeFrame
[read-only]
static
DidHideNotificationNSString. Notification constant for DidHide
[read-only]
static
DidShowNotificationNSString. Notification constant for DidShow
[read-only]
static
FrameBeginUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardFrameBeginUserInfoKey
[read-only]
static
FrameEndUserInfoKeyNSString. Represents the value associated with the constant UIKeyboardFrameEndUserInfoKey
[read-only]
static
IsLocalUserInfoKeyNSString.
[read-only]
static
WillChangeFrameNotificationNSString. Notification constant for WillChangeFrame
[read-only]
static
WillHideNotificationNSString. Notification constant for WillHide
[read-only]
static
WillShowNotificationNSString. Notification constant for WillShow

Public Methods

static
AnimationCurveFromNotification(NSNotification) : UInt32
Deprecated: helper method to extract the animation curve from a notification.
static
AnimationDurationFromNotification(NSNotification) : Double
Deprecated: helper method to extract the animation duration from a notification.
static
BoundsFromNotification(NSNotification) : RectangleF
Deprecated: helper method to extract the keyboard bounds from a notification.
static
CenterBeginFromNotification(NSNotification) : PointF
Deprecated: helper method to extract the center start from a notification
static
CenterEndFromNotification(NSNotification) : PointF
Deprecated: helper method to extract the center end from a notification.
static
FrameBeginFromNotification(NSNotification) : RectangleF
Deprecated: helper method to extract the keyboard's starting frame from a notification
static
FrameEndFromNotification(NSNotification) : RectangleF
Deprecated: helper method to extract the keyboard's ending frame from a notification