Tag: 等待

在Objective-C中如何等待

我想在2秒后更改我的UILabel的文本。 我尝试将我的UILabel的文本设置为“一个文本” ,并使用sleep(2) ,最后将文本更改为“另一个文本” 。 但sleep(2)只冻结了应用程序,并设置了“另一个文本” ,而不显示“文本” 2秒。 如何显示“文本” 2秒钟,然后显示“另一个文本” ?

显示等待警报视图在加载

我想当我的应用程序启动它显示一个警报视图约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 […]