Make custom keyboard not movable

We have created a special numeric keypad for the iPad. On our iPad testers, this keyboard suddenly turned out to be out of place, and it took us quite a while to realize that we could move this custom keyboard by dragging it where the Keyboard would normally be located.

Customers will have a very difficult time moving it back if they accidentally transfer it. Since it makes no sense to move the keyboard on this particular input screen, I would rather prevent the keyboard from moving, instead of drawing some kind of pen that makes it visible to users to move the keyboard. (This is a special input screen for editing only one numerical value. The keyboard is similar to part of the layout and is always visible on this screen.)

I tried, but could not find a way to prevent the keyboard from moving when dragging to the specified location. Even all my dirty ideas, like deleting, possibly, pre-existing GestureRecognizers (there were none) or placing my own button in front, did not help.

Edit: The keyboard even moves around in the simplest custom keyboard app written in Monotouch that I can think of. Did I miss something?

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace KeyboardTest
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    {
        private UIWindow window;
        private UIViewController viewController;
        private UIViewController keyboardViewController;

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            // Create a red dummy keyboard
            keyboardViewController = new UIViewController();
            keyboardViewController.View.BackgroundColor = UIColor.Red;

            // Create a textfield and assign our beautiful red keyboard as its InputView
            UITextField textField = new UITextField();
            textField.BorderStyle = UITextBorderStyle.RoundedRect;
            textField.Frame = new System.Drawing.RectangleF(44, 44, 200, 44);
            textField.InputView = keyboardViewController.View;

            // create a rootview controller and add our textfield
            viewController = new UIViewController();
            viewController.View.AddSubview(textField);

            window.RootViewController = viewController;
            window.MakeKeyAndVisible ();

            return true;
        }
    }
}
+3
source share
1 answer

For what you explain, I assume that you have a keyboard as a sub-view of your main view. Instead, I would set it as inputView for UItextFields, and then make the first of your text fields the first one responding to viewDidLoad. Sort of:

-(void)viewDidLoad{

[super viewDidLoad];

CustomkeyPad *keypad=[[CustomKeyPad alloc]init];  // initWithFrame would probably be better

self.textField.delegate=self;
self.textField.inputView=keypad;
[self.textField becomeFirstResponder];

}

I'm not on my Mac, so I probably made some kind of mistake here, but this is an idea, and this is how I did it when I made my own keyboard, and it is universal (iPad and iPhone) for both landscape and for portrait modes, and so far this has not given me any problems.

+1
source

All Articles