简体   繁体   English

适用于SDK 4(iOS4 OS)的自定义iPhone键盘

[英]Custom iPhone KeyBoard for SDK 4 (iOS4 OS)

Old SDK solution: 旧版SDK解决方案:

- (void)modifyKeyboard:(NSNotification *)notification 
{
    UIView *firstResponder = [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)];

    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows])
        for (UIView *keyboard in [keyboardWindow subviews])
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
            {
                MyFancyKeyboardView *customKeyboard = [[MyFancyKeyboardView alloc] initWithFrame: CGRectMake(0, 0, keyboard.frame.size.width, keyboard.frame.size.height);
                                                       [keyboard addSubview: customKeyboard];
                                                       [customKeyboard release];
            }
}

Following the above method, I now find that the iOS4 is different. 按照上述方法,我现在发现iOS4是不同的。 It will not work. 不起作用。 I am sure this is due to differences in naming subviews (or the sort). 我敢肯定这是由于命名子视图(或排序)的差异。 Does anyone know how to get around this same problem, for the iphone SDK 4? 有谁知道如何解决iphone SDK 4的相同问题?

You can have a look at this post: http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key 您可以看一下这篇文章: http : //www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key

It resolves the issue and works for all version of the SDK 它可以解决问题并适用于所有版本的SDK

Yes. 是。 iOS 4 supports custom input views—you can swap your own MyFancyKeyboardView in for any UIResponder-inheriting class (eg UITextField and UITextView )'s keyboard by setting the responder's inputView property. iOS 4支持自定义输入视图-您可以通过设置响应者的inputView属性,将自己的MyFancyKeyboardView交换为任何UIResponder继承类(例如UITextFieldUITextView )的键盘。

现在,4.1 SDK具有UIKeyboardTypeDecimalPad,这是您要尝试执行的操作,对吗?

for ios 5, it seems that doesn't work. 对于ios 5,似乎不起作用。 but when I change the code like this : 但是当我像这样更改代码时:

change UIKeyboard to UIPeripheralHostView UIKeyboard更改为UIPeripheralHostView

it works. 有用。 I hope it's useful for some other developer. 我希望它对其他一些开发人员有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM