我正在使用UITextField和UITextField.Mine是iPad应用程序
-(void)showAlertToAddLink
{
alertToAddLink =[[UIAlertView alloc] initWithTitle:@"" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"ADD", nil];
alertToAddLink.tag = 2;
alertToAddLink.alertViewStyle = UIAlertViewStylePlainTextInput;
[txtLinkName setDelegate:self];
/*
UITextField *txtLinkName = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 50.0)];
[txtLinkName setDelegate:self];
// txtLinkName.text=@"";
[txtLinkName setFont:[UIFont fontWithName:@"Helvetica" size:17.0]];
[txtLinkName setTextColor:[UIColor colorWithRed:71.0/255.0 green:78.0/255.0 blue:80.0/255.0 alpha:1]];
[txtLinkName setBorderStyle:UITextBorderStyleRoundedRect];
[txtLinkName setBackgroundColor:[UIColor whiteColor]];
[txtLinkName setKeyboardAppearance:UIKeyboardAppearanceAlert];
[txtLinkName setAutocorrectionType:UITextAutocorrectionTypeNo];
[txtLinkName setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[txtLinkName setClearButtonMode:UITextFieldViewModeWhileEditing];
[txtLinkName setTextAlignment:UITextAlignmentLeft];
// [txtLinkName becomeFirstResponder];
[alertToAddLink addSubview:txtLinkName];
*/[alertToAddLink show];
}
我试过
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[alertToAddLink resignFirstResponder];
return YES;
}
但是alertview没有被重新开始。
该怎么做
答案 0 :(得分:7)
将此行添加到textFieldShouldReturn:
。
这将在调用textFieldShouldReturn:
时触发警报视图的解除:
[alertToAddLink dismissWithClickedButtonIndex:alertToAddLink.cancelButtonIndex animated:YES];
希望有所帮助