1

我需要从键盘上删除特定的键。我环顾四周,发现了如何添加自定义键以及如何删除它们。但是,我需要删除一个内置密钥。例如,假设我想从键盘上删除 a 键。

下面的代码只是从视图中删除了整个键盘,这不是我想要的。

- (void)keyboardDidShow:(NSNotification *)aNotification {        
    for (UIWindow *keyboardWindow in [[UIApplication sharedApplication] windows]) 
    {   
        // Now iterating over each subview of the available windows
        for (UIView *keyboard in [keyboardWindow subviews]) {   
            // Check to see if the description of the view we have 
            // referenced is UIKeyboard.
            // If so then we found the keyboard view that we were looking for.
            if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)                    
                [[keyboard.subviews objectAtIndex:0]removeFromSuperview];                
        }            
    }
4

1 回答 1

0

您最好制作一个自定义键盘并添加您想要的键,而不是尝试更改内置键盘,这可能会破坏或导致批准问题。这里有些例子:

http://brygruver.squarespace.com/blog/2009/10/1/creating-a-custom-number-pad.html

http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/7350-adding-subviews-custimize-keyboard.html

于 2012-09-17T23:24:04.673 回答