在AppDelegate中显示加载消息

时间:2016-05-04 08:52:40

标签: ios objective-c appdelegate

我想在检查一些内容时在AppDelegate中显示加载消息,当我完成此任务并使用委托获取结果时,请忽略此消息。

我该怎么做?我实施了这个解决方案,但我无法解除警报。

我在这里发布警报:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    _alert_news = [[UIAlertView alloc]initWithTitle:@"" message: @"telo" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
    [_alert_news show];

    return YES;
}

在这里,在Appdelegate中,我收到了我的回复:

#pragma mark InitializeDelegate
-(void)checkState:(NSString*)State{

    NSLog(@"InitializeResult: %@",State);
    [_alert_news dismissWithClickedButtonIndex:0 animated:YES];

}

感谢

固定!! 最后我用这种方式解决了这个问题:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    _alert=   [UIAlertController
               alertControllerWithTitle:@""
               message:@"Loading GradiantFace ..."
               preferredStyle:UIAlertControllerStyleAlert];


    [self.window makeKeyAndVisible];
    [self.window.rootViewController presentViewController:_alert animated:YES completion:nil];


    return YES;
}

#pragma mark InitializeDelegate
-(void)checkState:(NSString*)State{

    NSLog(@"InitializeResult: %@",State);
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
    });


}

1 个答案:

答案 0 :(得分:2)

你不应该这样做。而是将第一个视图控制器创建为空白控制器,在加载东西时应该加载器(或消息),然后将其替换为主视图控制器。