iphone alertview与textfield [英] iphone alertview with textfield
问题描述
我有一个 UIAlertView
,其中有一个 UITextField
。我要输入邮件ID 并在 UIAlertView
的确定按钮中提交,但
没有回应,请帮助我。 UIAlertView
中的UITextField
I have an UIAlertView
with a UITextField
in it. I want to type the mail id and submit in UIAlertView
's ok button, but UITextField
in the UIAlertView
have no response, Please help me.
p>
推荐答案
从iOS 5中,不再需要上述方法。只需将 alertViewStyle
属性设置为适当的样式( UIAlertViewStyleSecureTextInput
, UIAlertViewStylePlainTextInput
或 UIAlertViewStyleLoginAndPasswordInput
)。
From iOS 5 the approach above is no longer necessary. Just set the alertViewStyle
property to the appropriate style (UIAlertViewStyleSecureTextInput
, UIAlertViewStylePlainTextInput
, or UIAlertViewStyleLoginAndPasswordInput
).
示例:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Enter your email:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
,您可以将回复为
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
UITextField *emailTextField = [alertView textFieldAtIndex:0];
NSLog(@"%@",emailTextField.text);
}
这篇关于iphone alertview与textfield的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!