增加延迟到PresentViewController
我想知道如何添加1.0秒的延迟这个赛格瑞我有我的代码:增加延迟到PresentViewController
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *homeViewController = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
[self presentViewController:homeViewController animated:YES completion:nil];
我知道你可以这样做:
[self performSelector:@selector(showModalTwo:)withObject:someNumber afterDelay:1.0f];
我只是不有这个或想做一个功能继续。任何帮助都很好。谢谢!
不建议用于等待的操作完成(即登录)增加延迟,而不是你可以使用大中央调度
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
//Background Thread
// do you login logic here
dispatch_async(dispatch_get_main_queue(), ^(void){
//Main Thread : UI Updates
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *homeViewController = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
[self presentViewController:homeViewController animated:YES completion:nil];
});
});
这很好 - 感谢帮助的人。我很感激! –
这不是实现这种延迟的好方法。如果您只想延迟演示文稿,请使用'dispatch_after'。 – rmaddy
其实他并不需要延迟,他需要在成功登录后在后台执行当前的视图控制器登录。如果他延迟使用dispatch_after,他将无法确定登录是否完成 –
你想延迟后执行SEGUE?或者是什么? –
是的 - 我只想让延迟时间过后发生。我有一个登录去,所以我想一旦我给它一个延迟,这将使登录足够的时间来获取我需要用这个segue trasnfer的信息 –