func checkForRecipes(noRecords: Bool) {
//segue to addNewRecipe page
if noRecords == true{
print("Can't Find any Recipes!")
self.performSegue(withIdentifier: "ToAddNewRecipeVC", sender: self)
}else{
print("error, noRecords not equal to zero")
}
我能够通过 Storyboard 成功进行 segue,但我想根据委托(delegate)返回的信息以编程方式进行。
在运行该应用程序时,来自委托(delegate)的信息已成功发送到函数“checkForRecipes”——即“noRecords”返回 TRUE,但由于某种原因,该函数中的以下代码行似乎没有执行(并且没有错误被抛出):
self.performSegue(withIdentifier: "ToAddNewRecipeVC", 发件人: self)
应用程序启动但停在主屏幕上,而它应该转到“AddNewRecipe” View Controller 。
segue 本身肯定有一个 segue ID“ToAddNewRecipeVC”。我还尝试根据以下 thread. 调度到主队列(无济于事)
我很困惑 - 这里出了什么问题?
最佳答案
OK,看来我的问题已经解决了。我将主视图 Controller 嵌入到导航 Controller 中,现在一切正常。我早些时候尝试过同样的策略,但它一直在抛出错误。咕噜咕噜!
无论如何 - 感谢大家的投入!
关于swift - performSegue(withSender : sender:) does not work - no errors displayed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40006887/