【发布时间】:2020-05-15 09:23:02
【问题描述】:
我有点困惑。 UINavagationController 的堆栈中有两个 UIViewControllers。我尝试在 second UIViewController 内调用 first UIViewController 的方法。见下面的代码
class VC1: UIViewController {
@objc func method1() {
//not called after tap button
}
}
class VC2: UIViewController {
let button = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
button.addTarget(nil, action: #selector(VC1.method1), for: .touchUpInside)
}
}
但是当我点击按钮时不会调用 method1。有什么问题?
【问题讨论】:
标签: swift uiresponder uievent