iphone alertview与textfield [英] iphone alertview with textfield

查看:66
本文介绍了iphone alertview与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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆