我有一个 UIAlertView,其中包含一个带有确定和取消按钮的 UITextField。当我单击确定按钮时,我正在调用 webService。我想在调用 web 服务之前返回键盘。直到响应不是来自 web 服务,键盘才会返回。由于在加载 web 服务期间用户看不到半屏。这是我做的代码。
UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"Forgot Password" message:@" " delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
// Adds a username Field
alertEmailtextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 29.0)];
alertEmailtextfield.layer.cornerRadius = 07.0f;
[alertEmailtextfield setBorderStyle:UITextBorderStyleRoundedRect];
alertEmailtextfield.placeholder = @"Enter Email";
[alertEmailtextfield setBackgroundColor:[UIColor whiteColor]];
alertEmailtextfield.autocapitalizationType =UITextAutocapitalizationTypeNone; //For Making Caps Off
[alertview addSubview:alertEmailtextfield];
[alertview show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
if ([alertEmailtextfield.text length] != 0) {
if (![self validEmail:alertEmailtextfield.text]) {
[AlertView UIAlertView:@"Enter email is not correct"];
}else{
//[alertEmailtextfield resignFirstResponder];
[NSThread detachNewThreadSelector:@selector(startSpinner) toTarget:self withObject:nil];
Boolean isForgotPassword = [serverConnection forgotPassword:alertEmailtextfield.text];
if (isForgotPassword) {
NSLog(@"Mail is send");
[AlertView UIAlertView:@"New password is send to your mail"];
[spinner stopAnimating];
}else{
[AlertView UIAlertView:@"User does not exist"];
[spinner stopAnimating];
}
}
}else{
[AlertView UIAlertView:@"Text Field should not be empty"];
}
}
}
如果有人知道如何在 UIAlertView 的 UITextField 中返回键盘,请帮助我。