我想知道如何在我的代码中添加1.0秒的延迟:
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];
我只是没有这个或想要制作一个功能来segue。任何帮助都会很棒。谢谢!
答案 0 :(得分:2)
不建议添加等待操作的延迟(即登录),而是可以使用Grand Central Dispatch
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];
});
});