我的应用程序中的一个屏幕显示带有HTML Web表单的UIWebView。目前,当文本场被聚焦并且键盘出现时,会显示Go按钮。目前我没有Go按钮的用户,点击它什么也没做。
如何禁用或删除此按钮,或如何更改UIWebView中显示的键盘?
答案 0 :(得分:2)
我认为你唯一的选择是在键盘显示时注册一个回叫,并获得键盘的UIView引用,并在键盘的Actual Go按钮上添加一个Disabled looking Go按钮。
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函数中遍历应用程序窗口的所有子视图以获取对键盘的引用..
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链接无耻地复制代码。看看它......一个信息非常丰富的帖子..
我不知道是否有任何其他方法..希望它会有用..