我有一个应用程序,其中包含许多 StoryBoards 和许多类似于下面的 segues - 除了我在下面显示的那个之外,所有的工作都很好。两个问题: 1. 我收到警告 2. 一个变量没有被转移
override func prepare(for segue: UIStoryboardSegue, sender: Any!) {
if (segue.identifier == "goToDetails") {
let nav3 = segue.destination as! UINavigationController
let svc3 = nav3.topViewController as! ActivityDetailTableViewController
svc3.majCat = majCat //Pass the category
svc3.subCat2 = subCat
print(subCat)
svc3.me = me
}
var subCat 是问题所在 - 打印显示它在调用 ActivityDetailTableViewController 之前有一个值 但随后消失了 - 我已经尝试了一切 - 重命名等没有任何帮助 - 其他 2 个变量都很好。
最佳答案
“丢失”var 的问题是一个简单错误的结果——一个很容易犯的错误——我从表行而不是 Storyboard开始,我为 Segue 做的准备看起来像: override func prepare(for segue: UIStoryboardSegue, sender: Any!) {
所以表行转场在 UIStoryboardSegue 之前执行! 警告问题仍然存在 - 我确定是因为我的 tableview 嵌入在 View 中。
关于ios - Swift 中的警告 : Attempt to present ---- whose view is not in the window hierarchy! 和一个变量未传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42325601/