views:

1001

answers:

3

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?

+3  A: 

Yes. iOS 4 supports custom input views—you can swap your own MyFancyKeyboardView in for any UIResponder-inheriting class (e.g. UITextField and UITextView)'s keyboard by setting the responder's inputView property.

Noah Witherspoon
Thanks for that, it is great to know. But what if I want access to the SDK's keyboard view in order to 'tweak' it? How do I reference the object instance to use?
You probably shouldn't be doing that. Among other things (likelihood of App Store rejection, potential for breaking in future builds, etc.), you can't rely on the keyboard even being onscreen—if the user's got a Bluetooth keyboard connected, they can enter text without the keyboard view ever appearing. What kind of “tweak” are you trying to implement?
Noah Witherspoon
Thanks Noah. I am actually trying to use iphone in-built number-only pad, and replacing the blanc space with a 'dot', which is actually a button with an image. when you click on the button it puts a dot in the first responder textfield.In the earlier SDK I could locate the keyBoard view, but this is not working on the SDK4.
I see now. Problem of returning UIKeyBoard object was because; while it was a UIView in older SDK, it is UIWindow in iphone SDK 4. Problem solved.Thanks Noah.
+1  A: 

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

Geraud.ch
A: 

The 4.1 SDK now has a UIKeyboardTypeDecimalPad which is what you're trying to do, right?

Fredrik