swift - Swift 中没有带有标识符错误的 Segue?

标签 swift function uiviewcontroller segue ibaction

我正在尝试使用performSegueWithIndentifier函数来创建从一个ViewController到下一个的segue。但是,当我按下连接有 UITApGestureRecognizer 的按钮时, View 将切换到调试器面板。

这是它显示的错误:

ContaminateTargetViewController: has no segue with identifier 'showMasterChemistryViewController'

(我删掉了个人信息)

这是 ViewControllers 类:

import Foundation
import UIKit

class ContaminateTargetViewController: UIViewController {
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showMasterChemistryViewController" {
            let chemistryMasterViewController = segue.destinationViewController as! ChemistryMasterViewController
        }

    }
@IBAction func showPlaylistDetail(sender: AnyObject) {
    performSegueWithIdentifier("showMasterChemistryViewController", sender: sender)
}
}

之前,我还必须从 ViewController 上的 2 个按钮手动切换,最近为了方便起见,删除了它们以切换到 UITapGestureRecognizer。我想知道我的代码中是否存在我看不到的错误,或者之前从 View 中删除手动转场是否导致了此错误。如果问题源于之前删除的手动转场,请告诉我如何解决您的错误。如果问题根源在于代码,请留下我应该添加、删除或替换的代码。

非常感谢任何建议或意见。

提前致谢。

最佳答案

当您没有将请求的 Segue 连接到 View Controller 时,会调用此错误。您确定您的 Storyboard上有一个名为“showMasterChemistryViewController”的 Segue 连接了两个 View Controller 吗?

关于swift - Swift 中没有带有标识符错误的 Segue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35121181/

相关文章:

c - 时间复杂度有何不同?

c++ - 为什么尽管我的函数和 cout 语句放置错误,我的程序仍能运行?

ios - QLPreviewController NavigationBar barTintColor

iphone - iOS - 带方向的反转高度/宽度

ios - SwiftUI 列表标题和副标题

swift - Xcode Storyboard 不更新自定义类 Designables

javascript - 将 javascript 函数转换为 Obj-C 函数

ios - xcode 中的多个目标导致内存管理的差异

c++ - 我如何发送(和接收)非常大的 float 数组从 Swift 到 Objective c++ 再到 c++,然后备份到 Swift?

json - 检查 WP REST API 的 JWT 身份验证中的 JSON 对象是否为 null