RSS

MonoTouch Tip #2 – Adding Keyboard Support.

11 May

To add support for keyboard input to your MonoTouch application you must first register for Notifications after your view as loaded.

NSObject obs1;

public override void ViewDidLoad ()
{
obs1 = NSNotificationCenter.DefaultCenter.AddObserver (
"UIKeyboardDidShowNotification", KeyboardUpNotification);
}

The next task is to set up the Notification method.

private void KeyboardUpNotification (NSNotification notification)
{
//Get the bounds of the keyboard...
RectangleF r = UIKeyboard.BoundsFromNotification(notification);
}

The keyboard bounds can then be used to move the view to keep textbox inputs visible. You will also need to wire up the textbox ShouldReturn event for each of your input text-boxes to scroll the view down when you are finished with the keyboard.

Advertisements
 
Leave a comment

Posted by on May 11, 2010 in MonoTouch

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: