Showing posts from November, 2013

Done button on iOS NumberPad with Xamarin

There are a ton of potential solutions on the Internet for adding a Done button to a NumberPad-type of UITextField on iOS.  Unfortunately most of them are old, use custom images or even require iterating through sub views to find the target keyboard. Below is a solution -- using Xamarin -- to add a Done button without fear of index-out-of-bound exceptions or using out-dated custom images. The trick is using the WeakInputDelegate of the UITextField & adding a custom button to that. A full working project is available on github . public override void ViewDidLoad () { base.ViewDidLoad (); // Your stuff NSNotificationCenter.DefaultCenter.AddObserver ("UIKeyboardWillShowNotification", KeyboardWillShow); } public void KeyboardWillShow(NSNotification notification) { var doneButton = new UIButton (UIButtonType.Custom); doneButton.Frame = new RectangleF (0, 163, 106, 53); doneButton.SetTitle ("DONE", UIControlState.Normal); do