需要从UIKeyboard中删除密钥

时间:2012-09-17 22:58:52

标签: iphone ios cocoa-touch uiview uikeyboard

我需要从键盘上删除特定键。我已经环顾了很多,我已经找到了如何添加自定义键以及如何删除它们。但是,我需要删除内置密钥。比方说,我想从键盘上删除一个键。

以下代码只是从视图中移除整个键盘,而不是我正在寻找的。

- (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];                
        }            
    }

1 个答案:

答案 0 :(得分: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