我想使用两个文本字段创建登录系统。我希望用户编辑第一个文本字段,并通过点击键盘上的下一个跳转到下一个文本字段,编辑后他应该点击去系统应该做的事情。所以我真正想要的是能够从一个文本字段跳转到下一个字段,当用户单击go按钮(女巫在第二个字段的键盘上)时,最重要的部分从两个字段中获取输入文本。我的文本字段都在IB中进行了标记。如果不是很清楚,我想实现与Podio的应用程序登录非常相似的内容。这是我迄今为止所拥有的。任何帮助非常赞赏:仅使用键盘从多个文本字段获取字符串
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
AppSettings *settings = [AppSettings sharedSettings];
NSString *password;
NSString *name;
if(textField == nameTextField)
{
name = textField.text;
NSLog(@"Name text field: %@",name);
}
if(textField == passwordTextField)
{
password = textField.text;
NSLog(@"Password text field: %@",password);
}
//this is where I send a call to the server
[[SessionInfo sharedInfo] loginWithEmail:settings.userEmailFromLogin
AndName:name AndPasswordRequest:password];
[textField resignFirstResponder];
return YES;
}
密码是一个字符串。它不能成为第一响应者。你可以说得更详细点吗?谢谢 – alex 2012-04-18 07:53:35
对不起,应该是passwordTextField。我重新编辑了我的答案。 – yibuyiqu 2012-04-19 00:38:58