English 中文(简体)
使自定义键盘不可移动
原标题:Make custom keyboard non-movable

我们为 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;
        }
    }
}
问题回答

对于您解释的, 我猜您将键盘作为您主视图的子视图。 相反, 我将它设置为输入 : 查看 UUtext Fields, 然后将您的第一个文本字段变成查看中的 Firs 响应器 。 例如 :

-(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];

}

我不是在Mac,所以我可能犯了一个错误, 但这就是我这样做的想法, 当我做我的定制键盘 和它的普遍性(iPad和iPhone) 对于景观和肖像模式, 并且到目前为止,它没有给我带来任何问题。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签