适用于SDK 4的自定义iPhone KeyBoard(iOS4操作系统)

use*_*961 1 iphone objective-c ios

旧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];
            }
}
Run Code Online (Sandbox Code Playgroud)

按照上面的方法,我现在发现iOS4是不同的.不起作用.我确信这是由于命名子视图(或排序)的差异.对于iphone SDK 4,有谁知道如何解决同样的问题?

Ger*_*.ch 6

你可以看一下这篇文章:http: //www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key

它解决了该问题,适用于所有版本的SDK


Noa*_*oon 5

是.iOS 4支持自定义输入视图 - 您可以通过设置响应者的属性来交换您自己MyFancyKeyboardView的任何UIResponder继承类(例如UITextFieldUITextView)的键盘inputView.