Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the keyboard


In this recipe, we will discuss some important aspects of the device's virtual keyboard usage.

Getting ready

In the previous recipe, we discussed how to edit text. In this recipe, we will discuss some of the things we can or even must do to use the keyboard effectively. Create a new iPhone Single View Application project in Xamarin Studio and name it KeyboardApp.

How to do it...

Perform the following steps:

  1. Open the KeyboardAppViewController.xib file in Interface Builder.

  2. Add a UITextField object in the bottom-half portion of the view and connect it to an outlet.

  3. Save the document.

  4. Back in Xamarin Studio, enter the following code in the KeyboardAppViewController class:

    private NSObject kbdWillShow, kbdDidHide;
    public override void ViewDidLoad()
    {
    
      base.ViewDidLoad();
    
      this.emailField.KeyboardType = UIKeyboardType.EmailAddress;
      this.emailField.ReturnKeyType = UIReturnKeyType.Done;
    
      this.kbdWillShow = UIKeyboard.Notifications.ObserveWillShow((s, e) => {RectangleF kbdBounds...