[英]Dismissing View Controller Doesn't Work While Using Navigation Controller
I have two view controllers. 我有两个视图控制器。
The first one is embedded in a Navigation Controller . 第一个嵌入在导航控制器中 。 On the first view controller there is Bar Button Item which is connected by a segue to the second view controller.
在第一个视图控制器上,有条形按钮项 ,该条按钮项通过缝线连接到第二个视图控制器。 The segue is set as Push.
将segue设置为Push。 Once I go to the second view controller there is a Bar Button Item which is an IBAction and should dismiss the page, but it doesn't.
一旦我转到第二个视图控制器,就会有一个Bar Button Item ,它是一个IBAction ,应该关闭该页面,但不是。
Second View Controller Code: 第二视图控制器代码:
import UIKit
class Page2ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func donePressed(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
}
Within your donePressed(_:)
function, access the navigation controller and call the popViewController(_:)
function. 在您的
donePressed(_:)
函数中,访问导航控制器并调用popViewController(_:)
函数。
@IBAction func donePressed(_ sender: Any) {
navigationController?.popViewController(animated: true)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.