Reputation: 1507
I Added the UI Tableview, and created unique Prototype Cell for each one:
I Attached UItableview cells to the unique Prototype Cells and gave each cell an identifier in the storyboard (also i put functions in each class to change the text, etc in that specific cell)
In my main UITableViewController, I set the size to a costume value that i change later,
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return tableSectionsSize
}
My question now is how do i setup the screen itself, with all i want and with the headlines and everything?
All the tutorials i find is for one tableview with all the data in the same kind, but in my case i have 8 different Prototype Cell.
Can u refer me to a tutorial for what I want to achieve? Or explain to me how I can build up the data itself when i have different Prototype Cell and i want to show\hide each one of them ?
Upvotes: 0
Views: 160
Reputation:
For tables, we got a method cellForAtIndexPath. Here according to your logic , you can choose and configure cell and then return it.
But if your layout is not gonna change, then it's better to use static tables. In static tables design your cells beforehand. It will work fine.
Upvotes: 0
Reputation: 138
You're probably referring to cells
and not sections
.
All the tutorials you find are talking about Dynamic Prototypes
kind of cells. By the Prototype Cells
that appears in your image, that's what your UITableView
is using. So the first thing is to switch it to Static Cells
in the Attribute Inspector
:
Then, add and customize each one of your TableViewCell's
as you already did. Add as much labels, buttons, switches, etc as you like. They'll be shown in the Document Outliner
as follows. You should now have 8 custom cells.
If you wish to group them logically, you should do as Craz1k0ek mentioned and separate them in sections, also in the Attribute Inspector
, dragging the cells to their corresponding sections.
No need to use numberOfSections(in tableView:)
method here.
I hope this helps.
Upvotes: 1