How do I create a UI TableView with multiple columns in Xcode?

后端 未结 3 1234
闹比i
闹比i 2021-02-03 12:43

I am working on a iOS 8 app with Xcode. I need to display a table with many columns and rows of data in one view.

Example:

Name               Time In             


        
3条回答
  •  温柔的废话
    2021-02-03 13:14

    iOS table views are always a single column. On Mac OS you can create what you are after directly.

    That said, you could create custom table view cells that display the content you want. In fact it would be quite easy. All you would do is to subclass UITableViewCell and define views (probably UILabels) for each of you columns, then wire them up as outlet properties in the cell. Then rig your table view to register that cell class for the cell identifier you use.

    You then write your cellForRowAtIndexPath method to install your data into the different outlet properties.

    You could also use a UICollectionView, but it looks to me like a table view with custom cells is a better fit for this application.

提交回复
热议问题