我的应用程序中的一个屏幕显示带有 HTML 网络表单的 UIWebView。当前,当文本字段获得焦点并且键盘出现时,会显示一个 Go 按钮。目前我没有 Go 按钮的用户,点击它也没有任何反应。
如何禁用或删除此按钮,或者如何更改显示在 UIWebView 中的键盘?
最佳答案
我认为您唯一的选择是在键盘显示时注册回调并获取对键盘的 UIView 引用,并在键盘中的实际转到按钮上添加一个看起来已禁用的转到按钮。
1) 首先注册keyboardWillshow通知..
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
2) 在您的 keyboardWillShow 函数中遍历应用程序窗口的所有 subview 以获取对键盘的引用..
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
//Iterate though each view inside of the selected Window
for(int i = 0; i < [tempWindow.subviews count]; i++){
keyboard = [tempWindow.subviews objectAtIndex:i];
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){
//Keyboard is now a UIView reference to the UIKeyboard we want. From here we can add a subview
//to th keyboard like a new button
}
}
代码无耻地复制自this链接..看看它..一个非常有用的线程..
我不知道还有没有其他方法..希望它有用..
关于iphone - 当文本字段聚焦在 UIWebView 中时,如何禁用 iPhone 键盘 Go 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5743748/