UIStoryboardSegue 子类识别 Segue 的种类

UIStoryboardSegue Subclass identify Kind of segue

class CustomSegue: UIStoryboardSegue {

    override init(identifier: String?, source: UIViewController, destination: UIViewController) {
        super.init(identifier: identifier, source: source, destination: destination)
    }

    override func perform() {

        self.source.navigationController?.pushViewController(self.destination, animated: true)

    }

}

在上面的代码中,我重写了 segue 的行为。 它应该使用 pushViewController 仅当类型是 Show(例如:Push) 对于其他类型它应该执行它可以执行的默认行为。

如何在子类perform()方法中找到segue的Kind

       override func perform() {

            if kind==Push { 
              self.source.navigationController?.pushViewController(self.destination, animated: true)
            } else {
              super.perform()
            }

        }

在情节提要中,select segue 作为自定义 segue,select kind 作为自定义 segue,默认行为只是 select 显示 segue(例如推送)