gpt4 book ai didi

ios - presentViewControler 将所有 Controller 压栈

转载 作者:行者123 更新时间:2023-11-28 08:24:21 26 4
gpt4 key购买 nike

我有一个 tableView 作为我的第一个 View 。每个单元格都是可点击的,在点击时,我使用 presentViewController 来显示带有新数据的当前 View 。我没有导航栏,所以我不能使用导航 Controller 和推送。问题是每次我点击一个单元格时,它都会显示一个新 View (这很好)但是在按下后退按钮时,它只会后退一步,但我想让它进入第一个 View 。我该怎么做?

print("clicked " + String(indexPath.row) )
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("playVideo") as! PlayVideoViewController

preferences.setValue( self.video[indexPath.row].id , forKey: "id" )
//self.dismissViewControllerAnimated(false, completion: nil)
self.presentViewController(vc, animated: true, completion: nil)

返回:

self.dismissViewControllerAnimated(true, completion: nil)

最佳答案

如果您想返回到第一个 VC,请使用该代码:

self.view.window!.rootViewController?.dismissViewControllerAnimated(true, completion: nil)

关于ios - presentViewControler 将所有 Controller 压栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40490473/

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