gpt4 book ai didi

ios - View Controller 不会立即显示

转载 作者:搜寻专家 更新时间:2023-10-31 22:44:14 26 4
gpt4 key购买 nike

在我的社交应用程序中,我有“主页”屏幕,其中有一个 tableView,其中最多包含 3 个不同的单元格!然后我实现了 didSelect 数据源方法,我在其中执行一些比较以确定我刚刚选择的单元格类型......(每次 3 或 4 次比较)对于我选择的每个单元格,一个新的 View Controller 被实例化......一个用于照片演示,另一个用于自定义相机演示,最后一个用于另一个简单的 View Controller 演示...

问题是,由于无法解释的原因,如果我按下 iPhone 主页按钮,然后再次打开我的应用程序并选择其中一个单元格,它最多需要 7 秒才能显示 View Controller !然后,如果我关闭该 View Controller ,返回“主页”并选择另一个单元格,一切正常!

有人知道会发生什么吗?

编辑:

if currentArea != "Somewhere" {
if gettingContent == false && objectsArray.count == 0 {
if firstOfLocalLeaderboard != nil {
if indexPath.row == 0 {
let vc = self.storyboard!.instantiateViewController(withIdentifier: "TopTenAreaController") as! TopTenAreaController
vc.area = currentArea

let navVC = UINavigationController()
navVC.viewControllers = [vc]

self.present(navVC, animated: true, completion: nil)
}
else if indexPath.row == 1 {
if localLeaderboard.count > 0 {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "PhotoViewController") as! PhotoViewController

vc.objectsArray = localLeaderboard
vc.currentArea = currentArea

let navVC = UINavigationController()
navVC.viewControllers = [vc]

self.present(navVC, animated: true, completion: nil)
}
else {
let vc = self.storyboard!.instantiateViewController(withIdentifier: "CameraViewController") as! CameraViewController
vc.appearedFromHome = true

let navVC = UINavigationController()
navVC.viewControllers = [vc]

self.present(navVC, animated: true, completion: nil)
}
}
}
else {
if indexPath.row == 0 {
if localLeaderboard.count > 0 {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "PhotoViewController") as! PhotoViewController

vc.objectsArray = localLeaderboard
vc.currentArea = currentArea

let navVC = UINavigationController()
navVC.viewControllers = [vc]

self.present(navVC, animated: true, completion: nil)
}
else {
let vc = self.storyboard!.instantiateViewController(withIdentifier: "CameraViewController") as! CameraViewController
vc.appearedFromHome = true

let navVC = UINavigationController()
navVC.viewControllers = [vc]

self.present(navVC, animated: true, completion: nil)
}
}
}
}

最佳答案

试试这个

DispatchQueue.main.async {
// present vc
}

关于ios - View Controller 不会立即显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40949487/

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