添加延迟到 PresentViewController

Add Delay to PresentViewController

我想知道如何为代码中的这个 segue 添加 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];

我只是没有这个或者想做一个函数来继续。任何帮助都会很棒。谢谢!

不建议为等待操作(即登录)添加延迟,而是可以使用 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];

        });
    });