I designed it with 1 Storyboard — 1 ViewController
in the application development in learning, but I noticed that I am always searching the net for methods for screen transitions, so I will post it as a memorandum.
The reason for designing with the above method is that the method of preparing one StoryBoard
for one ViewController
reduces conflicts in joint development.
【Xcode】Version 12.0.1 【Swift】Version 5.3
python
//Get the transition destination View (NextViewController)
let storyboard = UIStoryboard(name: "Next", bundle: nil)
let nextVC = storyboard.instantiateViewController(withIdentifier: "NextVC") as! NextViewController
//Screen transition to NextViewController
self.navigationController?.pushViewController(nextVC, animated: true)
python
//Get the transition destination View (NextViewController)
let storyboard = UIStoryboard(name: "Next", bundle: nil)
let nextVC = storyboard.instantiateViewController(withIdentifier: "NextVC") as! NextViewController
//Screen transition to NextViewController
self.present(nextVC, animated: true, completion: nil)
Storyboard
is instantiated, it is necessary to add Storyboard ID
. Be careful not to forget to check Use Storyboard ID
.There are still many ways to change screens, so I hope to update them as needed.
Recommended Posts