【发布时间】:2017-05-15 14:58:09
【问题描述】:
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 (e.g.: Push) 对于其他类型它应该执行它可以执行的默认行为。
如何在子类perform()方法中找到segue的Kind?
即
override func perform() {
if kind==Push {
self.source.navigationController?.pushViewController(self.destination, animated: true)
} else {
super.perform()
}
}
【问题讨论】:
标签: ios uinavigationcontroller uistoryboardsegue