Answer the question
In order to leave comments, you need to log in
Why doesn't it switch to another controller?
There is a test case with a basic controller
class TestController: UIViewController {
private let button = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
self.view.frame = CGRect(x: 0, y: 0, width: 1000, height: 1000)
self.view.backgroundColor = .red
print("TestController viewDidLoad")
button.setTitle("asxsas", for: .normal)
button.frame = CGRect(x: 5, y: 150, width: 100, height: 100)
self.view.addSubview(button)
}
}
class HomeController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
func get(){
self.switchAction()
}
@objc func switchAction(){
let view = TestController()
view.view.backgroundColor = .white
let navVC = UINavigationController(rootViewController: view)
present(navVC, animated: true)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question