iPhone UIWebview:如何强制使用数字键盘?是否可以? [英] iPhone UIWebview: How to force a numeric keyboard? Is it possible?

查看:40
本文介绍了iPhone UIWebview:如何强制使用数字键盘?是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PhoneGap 来开发一些 iPhone 应用程序.PhoneGap 基本上包装了一个 UIWebView - 它运行良好.问题是我的应用程序有几个只接受数字输入的输入字段.我真的需要强制使用数字键盘而不是接受默认的标准键盘,然后强制用户在每个字段上切换到数字.有谁知道这是否可能?怎么样?

I'm experimenting with PhoneGap to develop some iPhone apps. PhoneGap basically wraps a UIWebView - it works well. The problem is the my app has several input fields that only take numeric input. I really need to force the numeric keypad instead of accepting the default standard keyboard, which then forces the user to switch to the numeric on every field. Does anyone know if this is possible? How?

说明:我知道 Apple 目前没有提供任何 API 来允许这样做.我想知道创建一个从 UIWebView 继承的自定义类是否会有所帮助,或者创建一个自定义键盘是否会带来一些可能性?

Clarification: I know that Apple doesn't currently provide any API to allow this. I'm wondering if creating a custom class that inherited from UIWebView might help, or maybe creating a custom keyboard would open up some possibilities?

2009 年 11 月 6 日更新 - 如下所述,Apple 最近更新了 safari 功能,以便再次支持该功能.因此,已接受的答案已更改以反映这一点.

Update 6 Nov, 2009 - As noted below, Apple has recently updated safari functionality so that this is, once again, supported. So the accepted answer was changed to reflect that.

 <html>
<input type='tel'/>
<input type='number'/>
<input type='email'/>
<input />
</html>

推荐答案

看来 Mobile Safari 支持新的 HTML5 输入类型属性 emailnumbersearchtelurl.这些将切换显示的键盘.请参阅类型属性.

It looks like Mobile Safari supports the new HTML5 input type attributes of email, number, search, tel, and url. These will switch the keyboard that is displayed. See the type attribute.

例如,您可以这样做:

<input type="number" />

当输入框有焦点时,会显示数字键盘(就像用户有全键盘并按下123"按钮一样.

And when the input box has focus, the number keyboard is shown (as if the user had the full keyboard and hit the "123" button.

如果你真的只想要数字,你可以指定:

If you really only want numbers, you could specify:

<input type="tel" />

然后用户会得到电话号码拨号键盘.

And then the user would get the phone number dialing keypad.

我知道这适用于 Mobile Safari -- 我只假设它适用于 UIWebView.

I know this works with Mobile Safari -- I only assume it will work with UIWebView.

这篇关于iPhone UIWebview:如何强制使用数字键盘?是否可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆