Ios7 如何在IOS应用程序中使用UIAlertView验证登录?

Ios7 如何在IOS应用程序中使用UIAlertView验证登录?,ios7,uialertview,uialertviewdelegate,Ios7,Uialertview,Uialertviewdelegate,我已经为我的应用程序创建了登录名。我已经在iOS中编写了警报视图。代码如下: alertView = [[UIAlertView alloc] initWithTitle:@"Login" message:@"Enter username and password" delegate:se

我已经为我的应用程序创建了登录名。我已经在iOS中编写了警报视图。代码如下:

  alertView = [[UIAlertView alloc] initWithTitle:@"Login"
                                                    message:@"Enter username and password"
                                                   delegate:self
                                          cancelButtonTitle:nil
                                          otherButtonTitles:@"Login", nil];

alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;   
[alertView show];
我想检查用户名和密码以允许查看下一个表单。如果用户名和密码错误,则需要始终弹出警报视图

当用户名和密码错误时,如何始终弹出警报

任何想法或参考都应受到赞赏


提前感谢。

在视图控制器中,确保您实现了
UIAlertViewDelegate
协议

@interface MyCarsViewController () <UIAlertViewDelegate>
到视图控制器。在这里,您可以获取对警报中文本字段的引用,并执行数据库检查等操作,以获取对所使用文本字段的引用

textFieldAtIndex:
:

检查正确登录后,您可以根据登录结果显示其他视图控制器或显示其他警报


这很有帮助

@Mihal Popa:好的。如果密码错误,如何保持在警报框中?只需显示另一个显示“密码错误,请重试!”的警报,然后在用户单击-(void)alertView:(UIAlertView*)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex中的“确定”后,再次显示初始UIAlertViewStyleLogin和PasswordInput警报。在-(void)alertView:(UIAlertView*)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex方法中,您必须检查哪个警报被解除
textFieldAtIndex: