Swift - 解散ViewController太远了

时间:2018-04-30 05:51:31

标签: ios swift4

当我点击模式弹出式ViewController中的取消按钮时,出于某种原因,它会转到navigation堆栈的最开头,而不是返回到viewController那个叫它。我做错了吗?

堆栈的根,调用ViewControllerA:

class RootViewController {
    let viewController = ViewControllerA(contact: selectedContact)
    self.navigationController!.pushViewController(viewController, animated: true)
}

ViewControllerA /调用模式:

let viewController = ViewControllerB()
let navigationController = UINavigationController(rootViewController: viewController)
self.present(navigationController, animated: true, completion: nil)

ViewControllerB /解除模态:

@objc func cancelButtonPressed() {
    self.dismiss(animated: true, completion: nil)
}

0 个答案:

没有答案