我需要从键盘上删除特定的键。我环顾四周,发现了如何添加自定义键以及如何删除它们。但是,我需要删除一个内置密钥。例如,假设我想从键盘上删除 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];
}
}