gpt4 book ai didi

ios - 更改选项卡栏 Controller 的选定索引会显示黑屏

转载 作者:行者123 更新时间:2023-11-30 11:11:23 24 4
gpt4 key购买 nike

我正在尝试使用以下代码从一个 View Controller 导航到另一个 View Controller :

self.tabBarController?.selectedIndex = 1
self.tabBarController?.selectedViewController = self.tabBarController?.viewControllers![1]

当代码执行时,它会转到所需的UIViewController,但 View 会在短暂的延迟后出现,并且在此期间可以看到黑屏。

最佳答案

找到答案只需在主线程中运行代码

DispatchQueue.main.async {
self.tabBarController?.selectedIndex = 1
self.tabBarController?.selectedViewController = self.tabBarController?.viewControllers![1]
}

}

关于ios - 更改选项卡栏 Controller 的选定索引会显示黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52150357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com