2013-01-18 47 views
0

我正在IOS中使用phonegap框架創建應用程序。我有幾個輸入框是通過html/javascript中的phonegap創建的。我想爲其中一個輸入框輸入[UIKeyboardTypeEmailAddress]類型的軟鍵盤。IOS中特定輸入框的軟鍵盤類型

我在AppDelegate.h代碼如下:

@property (nonatomic, strong) IBOutlet UITextField* textField; 
- (void) setKeyboardType: (UIKeyboardType)newType; 

而對於AppDelegate.m,它如下:

@synthesize textField; 

//function definition 
- (void) setKeyboardType: (UIKeyboardType) newType 
{ 
    //NSLog(@"setKeyboardType: %@", newType); 
    textField.keyboardType = newType; 
} 

,並從另一個函數調用類似如下:

[self setKeyboardType: (UIKeyboardType) UIKeyboardTypeEmailAddress]; 

此代碼不適用於任何輸入框。另外,我怎麼能把這個特定的輸入框的條件有這種類型。輸入框ID可用。謝謝。

回答

0

如果您只想爲輸入顯示不同的鍵盤組,請檢查HTML5 input types

例如,當您將輸入的類型設置爲電子郵件時,iPhone會將@鍵鍵入鍵盤,因此輸入起來會更容易一些。

<input type="email" /> 

,或者當您將它設置爲數字,它顯示的數字鍵盤

<input type="number" /> 

HTML5輸入類型在其他平臺以及支持。

1

您是否嘗試過在HTML文本字段中使用'email'類型 - <input type="email" />