質問

私の実験をPhoneGapの開発を行iPhoneアプリとなります。PhoneGap基本的にラップUIWebView-うまく動作しています。問題は、私のアプリは、複数の分野だけで数値入力します。私は本当に必要な力は、数値キーパッドの代わりに受け入れ、デフォルトの標準キーボード、その勢力は、ユーザ切り替えるには、数値にする。なんだろうけど、日本人の場合可能ですか?いかがですか?

解明:知っているAppleさんの在庫を委託形式で預かる在庫リAPIリストを許可します。った場合をカスタムクラスから継承されたUIWebViewがいかなる貢献ができるかも作成したいキーボードのオンラインの一部の可能性?

更新6月2009年について下記のとおり、Apple最新のサファリの機能ですが、再び対応します。の受け答えをしたの人気予測を算出するのに使用する。

 <html>
<input type='tel'/>
<input type='number'/>
<input type='email'/>
<input />
</html>
役に立ちましたか?

解決

モバイルSafariは、のメールの、の数の、の検索のの新しいHTML5の入力タイプの属性をサポートしていますように

に見え、のTEL 、およびのURL の。これらは、表示されたキーボードを切り替えます。 type属性を参照してください。

したがって、たとえば、あなたはこれを行うことができます

<input type="number" />

と、入力ボックスにフォーカスがあるときに、ユーザーがフルキーボードを持っていた「123」ボタンを押しているかのように、数字キーボードが(示されています。

あなたが本当に唯一の数字をしたい場合は、あなたが指定できます:

<input type="tel" />

そして、ユーザが電話番号をダイヤルキーパッドを得るでしょう。

私は、これはモバイルサファリで動作します知っている - 私はそれがのUIWebViewで動作すると仮定します。

他のヒント

私はよりよい解決策は、両方のモバイルおよびデスクトップブラウザ用のフォームを設計する際<input type="text" pattern="[0-9]*">を使用することです見つけます。

<のhref = "からhttp://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TextandWeb/TextandWeb.html#//apple_ref/doc/uid/TP40007072-CH20-SW14 "REL =" nofollowをnoreferrer "> Appleのドキュメントの(のUIWebViewに関する注意):

  

あなたは、入力要素にキーボードの種類を指定することはできません。 Web表示はデフォルトのキーボードに基づいていますが、フォーム要素間を移動するためのいくつかの追加コントロールが含まれるカスタムキーボードを表示します。

IPhone OS 3.0上でチェック、この機能はなく、まだそこに今、この権利に取り組むことは本当に怒って、Appleはちょうどこの便利な機能を削除する理由確認されませんでした

ここでのiOS(4.0以上)Webビューと互換性のあるすべてのタイプのリストは、次のとおりです。

http://conecode.com/news/2011 / 12 /モバイルサファリ-のUIWebView-入力タイプ/

Safariは、名前に「郵便番号」または「電話」のフィールドを形成するために、数字のキーボードを与えるだろう - -

このは、iPhone OSの最初の反復可能であったが、それはiPhone OS 2.0で姿を消した。

のPhoneGapは、現時点ではこれを無効にするためにAPI機能を持っていません。それは、彼らが取り組んでいるものになることがあり、それは間違いなく気の利いた機能があると思います。

iOSのモバイルSafariはまた、サポートされています:

<input type="password" />

必要なものに変更のHTML部分のDashcodeプロジェクト:

  1. にDashcode開index.html コードウインドウです。
  2. キャンバス上のビューのまま選択入力フィールドにしたいで使用する設定の最適化をする必要があります。
  3. をクリックindex.html います。
  4. 編集"を選択しメニューから"検索"からDashcodeメニューバーがあります。
  5. タイプのボックスの正確な名称やりくりは夫婦で別にされていまへのテキストフィールドます。ページの制御にindex.html ファイルです。
  6. 変更のタイプから type="text"type="number".

行われます。

何ものiOSのPhoneGapベースのアプリケーションのために使用することができますことはあります:

input type="number" pattern="[0-9]*"

これは、以下の画像に示されています。 iOSの8.2およびPhoneGapの3.5以上で美しく動作します。

iOSのは、数字キーボードUIKeyboardTypeNumbersAndPunctuationを持っているが、これはHTML(<のhref = "https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagementから呼び出すことはできません.htmlの」REL = "nofollowをnoreferrer"> https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html の)

「TEL」キーボードのため、句読点は、あなた自身でこれを作成する必要がありません。 ios8カスタムキーボードが利用可能なので。それともあなたはちょうどあなたがボタンを追加することができます句読点が必要な場合(<のhref = "https://stackoverflow.com/questions/20192303/how-to-add-a-done-button-to-numpad-keyboard-in- ios7" >あなたはtype="number" pattern="[0-9]*"とあなたの入力フィールドを指定する際にポップアップ表示の数値キーボードへのiOS の中テンキーキーボード)に 『完了』ボタンを追加する方法。

これを行うには:Objective-Cのコードを

-(void)keyboardWillHide:(NSNotification *)note
{
    [self.donekeyBoardBtn removeFromSuperview];
    [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat: @"document.activeElement.blur()"]];
}

- (void)keyboardWillShow:(NSNotification *)note
{
    [UIView setAnimationsEnabled:NO];
    // create custom button
    //UIKeyboardTypeNumberPadin
    //type="number" pattern="[0-9]*"
    UIButton *extryB= [UIButton buttonWithType:UIButtonTypeRoundedRect];
    extryB.frame = CGRectMake(0, self.view.frame.size.height+150, 100, 50);
    extryB.backgroundColor = [UIColor colorWithRed:204.0f/255.0f
                                             green:210.0f/255.0f
                                              blue:217.0f/255.0f
                                             alpha:1.0f];
    extryB.adjustsImageWhenHighlighted = NO;
    extryB.titleLabel.font = [UIFont systemFontOfSize:14.0];
    [extryB setTitle:@"," forState:UIControlStateNormal];
    [extryB setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [extryB addTarget:self action:@selector(extryBpressed) forControlEvents:UIControlEventTouchUpInside];



self.donekeyBoardBtn = extryB;

// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++)
{
    keyboard = [tempWindow.subviews objectAtIndex:i];
    // keyboard view found; add the custom button to it

    if([[keyboard description] hasPrefix:@"<UIInputSetContainerView"] == YES)
    {

        for(int i = 0 ; i < [keyboard.subviews count] ; i++)
        {
            UIView* hostkeyboard = [keyboard.subviews objectAtIndex:i];

            if([[hostkeyboard description] hasPrefix:@"<UIInputSetHost"] == YES)
            {
                UIButton* donebtn = (UIButton*)[hostkeyboard viewWithTag:67123];
                if (donebtn == nil){
                    //to avoid adding again and again as per my requirement (previous and next button on keyboard)

                    if([[self printKeyboardType] isEqualToString: @"UIKeyboardTypePhonePad"]){
                        [keyboard addSubview:extryB];
                    }

                }
            }
        }
    }
    //[keyboard addSubview:extryB];
}
[UIView setAnimationsEnabled:YES];
// animate
[UIView animateWithDuration:0.5 animations:^{
    extryB.frame = CGRectMake(0, self.view.frame.size.height-50, 100, 50);
}];
}

-(NSString*)printKeyboardType
{

NSString* strKeyboardType = @"";
switch (self.textDocumentProxy.keyboardType) {
    case UIKeyboardTypeAlphabet:
        strKeyboardType = @"UIKeyboardTypeAlphabet";
        break;
    case UIKeyboardTypeDecimalPad:
        strKeyboardType = @"UIKeyboardTypeAlphabet";
        break;
    case UIKeyboardTypeDefault:
        strKeyboardType = @"UIKeyboardTypeDefault";
        break;
    case UIKeyboardTypeEmailAddress:
        strKeyboardType = @"UIKeyboardTypeEmailAddress";
        break;
    case UIKeyboardTypeTwitter:
        strKeyboardType = @"UIKeyboardTypeTwitter";
        break;
    case UIKeyboardTypeNamePhonePad:
        strKeyboardType = @"UIKeyboardTypeNamePhonePad";
        break;
    case UIKeyboardTypeNumberPad:
        strKeyboardType = @"UIKeyboardTypeNumberPad";
        break;
    case UIKeyboardTypeNumbersAndPunctuation:
        strKeyboardType = @"UIKeyboardTypeNumbersAndPunctuation";
        break;
    case UIKeyboardTypePhonePad:
        strKeyboardType = @"UIKeyboardTypePhonePad";
        break;
    case UIKeyboardTypeURL:
        strKeyboardType = @"UIKeyboardTypeURL";
        break;
    case UIKeyboardTypeWebSearch:
        strKeyboardType = @"UIKeyboardTypeWebSearch";
        break;
    default:
        strKeyboardType = @"UNKNOWN";
        break;
}
NSLog(@"self.textDocumentProxy.keyboardType=%@", strKeyboardType);
return strKeyboardType;
}

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

- (void)extryBpressed{
    //simulates a "." press
    [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat: @"simulateKeyPress('.');"]];
}

次に、あなたのJSコードで幅広いアプリケーションにアクセスすることができる方法を追加する必要があります。

simulateKeyPress: function(k) {
        var press = jQuery.Event("keypress");

        press.which = k;
        // place the id of your most outer html tag here
        $("#body").trigger(press);
            // just needed because my active element has a child element where the value should be placed in
                var id = document.activeElement.id.indexOf("-");
                if(id != -1){
                    var currentTf = sap.ui.getCore().byId(document.activeElement.id.split("-")[0]);
                    //append the value and set it (my textfield has a method setValue())
                    var currentTfValue = currentTf.getValue();
                    currentTf.setValue(currentTfValue + k);
                }
            },
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top