Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 从ViewController推送到TabBarController需要延迟_Xcode_Swift - Fatal编程技术网

Xcode 从ViewController推送到TabBarController需要延迟

Xcode 从ViewController推送到TabBarController需要延迟,xcode,swift,Xcode,Swift,在我的项目中,我有一个用于登录的ViewController A,当我按下登录按钮时,它会显示ViewController B,其中我有四个按钮。当我点击按钮1时,我有showSegue direct to TabBarController,它有两个选项卡。与按钮2、3、4相同,我已将showSegue指向导航控制器。实际上,这是我的TabBarController和NavigationController的层次结构: 单击按钮1以: TabBarController -> Tab1 -

在我的项目中,我有一个用于登录的ViewController A,当我按下登录按钮时,它会显示ViewController B,其中我有四个按钮。当我点击按钮1时,我有showSegue direct to TabBarController,它有两个选项卡。与按钮2、3、4相同,我已将showSegue指向导航控制器。实际上,这是我的TabBarController和NavigationController的层次结构:

单击按钮1以:

TabBarController -> 
Tab1 -> NavigationController -> ViewController1
Tab2 -> NavigationController -> ViewController2
单击按钮2,3,4以:

NavigationController -> ViewController
我在这个运行Swift 2,Xcode 7的项目中使用了故事板。当我点击每一个按钮时,都会延迟1-2秒,尤其是在iPad real设备上。糟糕的用户体验。我花了一段时间寻找一些答案,但遗憾的是,我没有找到解决方案,这就是为什么我在这里问这个问题


提前感谢。

当您按下按钮时,您可能应该考虑使用异步方法加载控制器

尝试使用

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {

//Background Thread (Get your values - Run your requests)



dispatch_async(dispatch_get_main_queue(), {

//Update the UI (Give values to your outlets)

    });
})

谢谢分享你的想法,但我解决了问题。。。实际上,在我的应用程序中,我覆盖了其中一种导航方法,我用图像更改了导航栏的背景。图像太大,这就是为什么它在显示下一个视图之前会造成一些延迟。更改图像大小后,它现在可以正常工作。

实际上,我只是在我的故事板中使用showSegue将按钮1连接到tabbarcontroller。也许你在viewDidLoad中有时间消耗代码?