0

我正在IOS中创建一个带有phonegap框架的应用程序。我有一些通过 html/javascript 中的 phonegap 创建的输入框。我想为其中一个输入框设置 [UIKeyboardTypeEmailAddress] 类型的软键盘。

我在 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 可用。谢谢。

4

2 回答 2

1

您是否尝试过在 html 文本字段中使用“电子邮件”类型 - <input type="email" />

于 2013-01-18T14:31:13.473 回答
0

如果您只想为您的输入显示不同的键盘设置,请检查HTML5 input types

例如,当您将输入类型设置为电子邮件时,iPhone 会在键盘上放置一个 @ 键,因此输入起来会更容易一些。

<input type="email" />

或者当您将其设置为数字时,它会显示数字键盘

<input type="number" />

其他平台也支持 HTML5 输入类型。

于 2013-01-18T14:31:50.870 回答