I'm a little confused. There are two UIViewControllers
in UINavagationController
's stack. I try to call the method of first UIViewController
within the second UIViewController
. See code below
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)
}
}
But method1 isn't called when I tap on the button. What's the problem?