swift - performSegue(withSender : sender:) does not work - no errors displayed

标签 swift segue swift3 xcode8

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/

相关文章:

ios - 如何在不同的 Storyboard 中对导航堆栈中的某些 View Controller 执行推送 segue?

ios - 实例化ViewControllerWithIdentifier并传递数据

swift - UITapGestureRecognizer 崩溃应用程序..?

swift - 如何快速使用 CFURLCreateFromFileSystemRepresentation ?

swift Mac 操作系统 : blank page printed when I try to print webView (WKWebView)

Swift - 通过侧面菜单在它们之间切换时保留实例化的 View Controller

swift3 - 在 Swift 3 中,UIEdgeInsetsMake 可用

javascript - 如何解析和显示 TVML 文件中的 JSON 数据

ios - 如何将坐标从 didUpdateLocation 传送到某个 View Controller ?

swift - 在运行时切换 iCloud 同步