【发布时间】:2021-12-16 22:16:36
【问题描述】:
您好,我正在学习 Xcode 来制作 ios 应用程序。我有问题
这是错误代码 -> 线程 1:“-[UIViewController back2:]:无法识别的选择器发送到实例 0x14fb0e270”
第一个 ViewContorller 代码 ->
import UIKit
class ViewController: UIViewController {
@IBAction func moveByNavi(_ sender: Any) {
guard let uvc = self.storyboard?.instantiateViewController(withIdentifier: "SecondVC") else {
return
}
self.navigationController?.pushViewController(uvc, animated: true)
}
@IBAction func movePresent(_ sender: Any) {
guard let uvc = self.storyboard?.instantiateViewController(withIdentifier: "SecondVC") else {
return
}
uvc.modalPresentationStyle = .fullScreen
self.present(uvc, animated: true)
}
}
第二个 ViewContorller 代码 ->
import UIKit
class SecondViewController: UIViewController {
@IBAction func back(_ sender: Any) {
self.presentingViewController?.dismiss(animated: true)
}
@IBAction func back2(_ sender: Any) {
_ = self.navigationController?.popViewController(animated: true)
}
}
每当我在第二个视图控制器上单击返回和返回 2 按钮时,我的模拟器就会停止。并在 appDelegate 上显示该错误代码。
我检查了第二个视图控制器的连接检查器。后退按钮连接良好。我也没有其他联系。 如何修复我的代码?
【问题讨论】: