Can you create a table with Swift that contains multiple columns?

Asked

Viewed 350 times

1

I need to assemble a table with multiple columns with the details of the customer’s purchase, but with the tableView I can only create tables with one column, can I use the tableView or something else to create a table with multiple columns? Follows the way I need to present the data:

Tabela com mais de uma coluna

  • 1

    You could create a class that inherits from Uitableviewcell and create a custom cell by dividing it into how many columns you want. Just imagine this example above being the cell with several cells delimiting spaces, forming columns.

1 answer

3


You can user an Uicollection, which has exactly this grid behavior (excel type) https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/

But apparently, in your case, a Uitableview, with a Cell prototype, is enough.

This is because, the user does not need to click on a distinct field, he probably selects the entire "line".

Just drag to prototype Cell from your table the Uilabels you need (one for password, one for rate, value, etc).

It works as a template for table rows, so you can create a custom class you inherit from Uitableviewcell (as @Jadson said in the comments) to link to @Iboutlet, or access via Tags.

Reference:
Uicollectionview
Uitableview

Tutorial Prototype Cells:
http://www.raywenderlich.com/113388/storyboards-tutorial-in-ios-9-part-1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.