アプリの起動時にアラート ビューを約 5 秒間表示した後、バックグラウンド プロセスの結果に応じて、別のアラート ビューが表示されるようにしたいと考えています。
私が経験している問題は、スリープを使用してバックグラウンド プロセスが発生するのを待機しようとしたときです。最初のアラートは表示されず、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];
}
}