In this recipe, we will discuss some important aspects of the device's virtual keyboard usage.
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
.
Perform the following steps:
Open the
KeyboardAppViewController.xib
file in Interface Builder.Add a
UITextField
object in the bottom-half portion of the view and connect it to an outlet.Save the document.
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...