我们为 iPad 创建了一个自定义数字键盘。 在我们的测试器 iPad iPad 上, 这个键盘突然被移出位置, 我们花了相当长的时间才发现, 可以通过拖动“ 键盘按钮” 通常的位置来移动该自定义键盘 。
客户若不小心移动键盘, 就会有非常困难的时间将键盘移回。 将键盘移到特定的输入屏幕上是毫无意义的, 我宁愿阻止键盘移动, 而不是画出某种能让用户看到键盘可以移动的控点。 (这是用于编辑单个数字值的特殊输入屏幕。 键盘和布局一样, 并且总是可以在屏幕上看到) 。
我尽力了,但找不到办法阻止键盘在这个特定地方被拖动时移动。 甚至连我所有的肮脏想法,比如删除可能存在的手势识别器(没有)或将自己的按钮放在前面,都无济于事。
Edit: The keyboard is even movable in the simplest possible custom keyboard app written in Monotouch I can think of. Did I missed 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;
}
}
}