iPhone UIWebview: How to force a numeric keyboard? Is it possible?

后端 未结 10 1527
清酒与你
清酒与你 2020-12-02 09:34

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

相关标签:
10条回答
  • 2020-12-02 10:09

    Here is a list of every type compatible with iOS (4.0 and greater) web views:

    http://conecode.com/news/2011/12/mobile-safari-uiwebview-input-types/

    0 讨论(0)
  • 2020-12-02 10:11

    Checked on IPhone OS 3.0, this functionality was still not there, not sure why Apple just removed this handy functionality, really upset to work on this right now :(

    0 讨论(0)
  • 2020-12-02 10:11

    iOS Mobile Safari also supports:

    <input type="password" />
    
    0 讨论(0)
  • 2020-12-02 10:13

    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.

    So for example, you could do this:

    <input type="number" />
    

    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.

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

    0 讨论(0)
  • 2020-12-02 10:14

    You need to make the change in the HTML portion of your Dashcode project:

    1. In Dashcode open index.html in the code window.
    2. On the canvas of the view you are working on, select the input field that you want to set to use the optimized keyboard.
    3. Click on index.html to give it focus.
    4. Select edit>find from the Dashcode menu bar.
    5. Type into the find box the exact name you gave to the text field control. Find will locate the control in the index.html file.
    6. Change the type from type="text" to type="number".

    Done.

    0 讨论(0)
  • 2020-12-02 10:18

    This was possible in the first iteration of the iPhone OS - Safari would give numeric keyboards to form fields with 'zip' or 'phone' in their names - but it disappeared in iPhone OS 2.0.

    PhoneGap doesn't have an API function to override this at the moment. It may be something they're working on, it'd definitely be a nifty feature.

    0 讨论(0)
提交回复
热议问题