Custom iPhone KeyBoard for SDK 4 (iOS4 OS)
Old SDK solution:
- (void)modifyKeyboard:(NSNotification *)notification
{
UIView *firstResponder = [[[UIApplication sh开发者_高级运维aredApplication] 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 (e.g. UITextField
and UITextView
)'s keyboard by setting the responder's inputView
property.
The 4.1 SDK now has a UIKeyboardTypeDecimalPad which is what you're trying to do, right?
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.
精彩评论