简体   繁体   中英

Custom iPhone KeyBoard for SDK 4 (iOS4 OS)

Old SDK solution:

- (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. 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?

You can have a look at this post: 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

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.

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

for ios 5, it seems that doesn't work. but when I change the code like this :

change UIKeyboard to UIPeripheralHostView

it works. I hope it's useful for some other developer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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