当文本字段聚焦在 UIWebView 内时,如何禁用 iPhone 键盘的 Go 按钮?

发布于 2024-11-02 20:16:23 字数 151 浏览 6 评论 0原文

我的应用程序中的一个屏幕显示了一个带有 HTML Web 表单的 UIWebView。目前,当文本字段获得焦点并且键盘出现时,会显示“Go”按钮。目前我没有“Go”按钮的用户,单击它不会执行任何操作。

如何禁用或删除此按钮,或者如何更改 UIWebView 中显示的键盘?

One the screens within my app shows a UIWebView with a HTML web form. Currently when a textfield is focused and the keyboard appears a Go button is shown. Currently I have no user for the Go button and clicking it does nothing.

How can this button be disabled or removed, or how can I change the keyboard that is showing in a UIWebView?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷炫老祖宗 2024-11-09 20:16:23

我认为您唯一的选择是在键盘显示时注册回调,并获取对键盘的 UIView 引用,并在键盘中的实际 Go 按钮上添加一个看起来已禁用的 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
}
}

代码无耻地从 链接..看看它..信息非常丰富的线程..

我不知道是否还有其他方法在那里..希望它会有用..

I think the only option you have is to register for a call back when keyboard will show and get a UIView reference to the keyboard and add a Disabled looking Go button over the Actual Go Button in the keyboard.

1) First register for keyboardWillshow notification..

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

2) IN your keyboardWillShow function traverse through all subViews of app window to get a reference to keyboard..

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
}
}

code shamelessly copied from this link..Look at it..a very informative thread..

I dont know if any other method out there..Hope it will be useful..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文