Ios UIAlertView在调用loginButton操作后显示太短

Ios UIAlertView在调用loginButton操作后显示太短,ios,login,request,action,uialertview,Ios,Login,Request,Action,Uialertview,我想在LoginProcess运行时或调用loginButton操作后显示UIAlertView。这是我的密码: - (void) btnLogin:(id) sender { UIAlertView *alertLogin = [[UIAlertView alloc] initWithTitle:nil message:@"\nLogin in progress, please wait!" delegate:self cancelButtonTitle:nil otherButto

我想在LoginProcess运行时或调用loginButton操作后显示UIAlertView。这是我的密码:

- (void) btnLogin:(id) sender {

    UIAlertView *alertLogin = [[UIAlertView alloc] initWithTitle:nil message:@"\nLogin in progress, please wait!" delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    [alertLogin show];

    NSURL *url = [NSURL URLWithString:@"http://www.example.com/login/"];

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

    [request setPostValue:username forKey:@"username"];
    [request setPostValue:password forKey:@"pw"];

    [request startSynchronous];
    [request cancelAuthentication];

    [...]
}
  • 我按下登录按钮
  • 屏幕上有一个灰色的放射状覆盖层
  • 3。登录过程已完成,现在UIAlertView很快就会出现。

    我想在登录过程中而不是之后显示UIView。 我不知道为什么在进展之后会出现这种情况。
    需要帮助。
    非常感谢你的建议。

    在你班的.h中

    UIAlertView *alert;
    
    In.m btnLogin方法

        alert = [[[UIAlertView alloc] initWithTitle:@"Login in progress\nPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
    
    [警报显示]

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    
    // Adjust the indicator so it is up a few pixels from the bottom of the alert
    indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
    [indicator startAnimating];
    [alert addSubview:indicator];
    [indicator release];
    
    在didReceiveData方法的连接中,您将编写,或者如果您正在解析,那么didEndDocument方法的解析器,您可以这样做

    [alert dismissWithClickedButtonIndex:0 animated:YES];
    

    您的问题在
    [请求启动同步]


    同步http请求和UI不能很好地结合在一起。尝试使用异步连接

    Hello Veer,这不起作用。登录进程/加载时屏幕被阻止。你向我推荐了MBD,但也有同样的问题。