IOS multiple class correspond to one viewcontroller

  1. create two viewcontroller, the first is to make a list of table view provinces in China, and the other detail view is to display the specific content corresponding to the relevant information of each province when you click on table view"s cell.
  2. The content in the
  3. detail view is loaded according to the user"s choice in the table view.
  4. can I make 32 class, that is, .swift files, each with different content. Then, based on the user"s click, determine which class"s content can be displayed in the detail view. So I don"t have to do 32 detail view.

or is there a better way?

May.27,2021

I don't understand what you're trying to say.
Click cell in tableVC to pass in the data you need to display in DetailVC and jump to
DetailVC to display the page based on the incoming data.
Why do you need 32 Class or 32 DetailVC


I understand your problem is that you have to show 32 kinds of content, right?
that must not be creating 32 Detail View.
you should click from tableVC and pass something similar to ID to detailVC, and then detailVC will load and display different content according to ID.

you need to follow MVC or MVVM mode. The content can actually be that your Model,Model data can come from a json file. After initializing the Model, pass it to detailVC.


what? It is more appropriate to use UISplitViewController in this situation.
you can take a look at this raywenderlich tutorial: Click me

.
Menu