1

我更新了一年后为 SDK 5.X 创建的应用程序,但现在,我遇到了一个可怕的问题。在应用程序中,使用 MBProgressHUD 从服务器下载文件,并在完成时显示 UIAlerView。但是,因此,视图闪烁,有人说 UIAlertView 应该在主线程上消失,我的代码是这样的:

    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithWindow:[[WNMAppDelegate appDelegate] window]];
hud.labelText = @"Please wait...";
[[[WNMAppDelegate appDelegate] window] addSubview:hud];
[hud showAnimated:YES whileExecutingBlock:^{
    [self progressHudMethodForCheckIn:dic];
} completionBlock:^{
    [hud removeFromSuperview];
    [hud release];
    if ([[dic allKeys] count])
    {
        NSString *key = [[dic allKeys] objectAtIndex:0];
        [self alertMessage:[dic objectForKey:key] withTitle:key];
    }
    else
    {
        [self alertMessage:@"Succeed sign in" withTitle:@"Nice"];
    }
}];
[dic release];

- (void)alertMessage:(NSString *)message withTitle:(NSString *)title{
UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:title
                      message:(NSString *)message
                      delegate:nil
                      cancelButtonTitle:@"OK"
                      otherButtonTitles:nil];
[alert show];
[alert release];

}

有人能帮我吗?谢谢你。

4

0 回答 0