假设我有一个分割 View Controller : 1.主视图 Controller :内部有 View Controller 的导航 Controller ,其中嵌入了 TableView Controller 2. 详细 View Controller 。它取决于应传递给它的某些值(否则它将无法正常工作,应用程序将崩溃)
基本上,详细 View Controller 需要额外的初始化步骤,并且应该向其传递一些值,否则应用程序将崩溃。现在我知道如何在单击 TableView 行时传递此值,但问题是:如何第一次执行此初始化?我必须这样做,否则分割 View Controller 已经使用关联的详细 View Controller 进行了初始化,如果未传递此值,则会崩溃。是否有任何回调可以监听以传递该值?
最佳答案
Let say you have 2 View Controllers:
ListViewController which has a list of your data
DetailViewController which display the details of the data that you tapped from first ViewController
So if you want to pass your data and set it to your ViewController's components, you can declare some variables to store those data and then you can set those data to your components in
override func viewDidLoad(){}
I hope this could answer your question and help.
关于ios - 如何将初始值传递给分割 View Controller 的详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58191701/