我希望当我的应用程序启动时它显示大约 5 秒的警报视图,然后根据后台进程的结果,它将显示另一个警报视图。
我遇到的问题是,当我尝试使用 Sleep 来等待后台进程发生时。第一个警报不显示并等待 5 秒。该应用程序显示应用程序的第一个视图,然后在 5 秒后短暂显示第一个警报。
我需要做什么来执行我想要的。
这是我的代码。
- (void)viewDidAppear:(BOOL)animated
{
SSGlobalSettings *connSettings = [SSGlobalSettings sharedManager];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Connecting" message:@"Please wait, while your device connects" delegate:Nil cancelButtonTitle:nil otherButtonTitles: nil];
[alertView show];
[NSThread sleepForTimeInterval:5.0f];
[alertView dismissWithClickedButtonIndex: alertView.cancelButtonIndex animated: YES];
if ([connSettings.connectionStatus isEqual: @"Not Found"])
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:@"Cannot find your device on the network" delegate:Nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Connection Success" message:@"WYour device has been found on the network" delegate:@"OK" cancelButtonTitle:nil otherButtonTitles: nil];
[alertView show];
}
}