我想从查看B 到查看C 执行segue,我在 A类中调用方法。 我在B类中的segue方法是 -
//ViewController B
func nextViewAction() -> Void {
self.performSegueWithIdentifier("nextview", sender: self)
}
我在A级这样称呼它 -
//ViewController A
@IBAction func sideMenuAction(sender: AnyObject) {
ViewClassB().nextViewAction()
}
但它崩溃 - 由于未捕获的异常终止应用' NSInvalidArgumentException',原因:' Receiver()没有带标识符的segue' nextview&#39 ;'
答案 0 :(得分:1)
答案 1 :(得分:0)
你可以拥有的是从第一个viewcontroller移动到第三个viewcontroller跳过第二个使用下面的代码..
class MyViewController: UIViewController, UINavigationControllerDelegate {
var viewControllerToInsertBelow : UIViewController?
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.delegate = self
}
func pushTwoViewControllers() {
if let viewController2 = self.storyboard?.instantiateViewControllerWithIdentifier("id1"),
let viewController3 = self.storyboard?.instantiateViewControllerWithIdentifier("id2") { //change this to your identifiers
self.viewControllerToInsertBelow = viewController2
self.navigationController?.pushViewController(viewController3, animated: true)
}
}
//MARK: - UINavigationControllerDelegate
func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
if let vc = viewControllerToInsertBelow {
viewControllerToInsertBelow = nil
let index = navigationController.viewControllers.indexOf(viewController)!
navigationController.viewControllers.insert(vc, atIndex: index)
}
}
}
参考:SO Post
答案 2 :(得分:0)
不要使用任何其他代码 通知观察员它将解决您的问题。
谢谢
答案 3 :(得分:-1)
我认为你无法从AViewController触发segue动作,因为它是什么 performSegue的确如此:
Initiates the segue with the specified identifier from the current view controller's storyboard file.
尝试实现从A到C的segue