如何在Xcode中创建具有多个列的UI TableView? [英] How do I create a UI TableView with multiple columns in Xcode?

查看:129
本文介绍了如何在Xcode中创建具有多个列的UI TableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode开发iOS 8应用程序。
我需要在一个视图中显示一个包含许多列和行数据的表。

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.

示例:

Name               Time In       Time Out      ETA
Johnnys Supplies    8:30AM        9:00AM      10:15AM
Franks Company      8:45AM        9:05AM      9:45AM
Another Inc.        10:12AM       11:00AM     12:04PM

所有数据都将被读取用JSON / PHP。

All of the data would be read in with JSON/PHP.

我需要它像桌面一样工作,用户可以垂直滚动,并选择一个索引。选择该索引后,用户可以单击按钮以根据所选单元格中的数据运行其他查询(等)。

I need it to work like a tableview where a user can scroll vertically, and select an index. Once that index is selected, the user can click a button to run additional queries based on the data in the selected cell (etc.).

实现这个的最简单方法是什么?必须有一种方法xcode允许你本地执行此操作?我错过了什么吗?

What is the easiest way to implement this? There has to be a way xcode allows you to do this natively? Am I missing something?

欢迎所有编码示例!

我找到了两个选项,但都需要许可费:

I have found two options but both require licensing fees:

http://www.ioscomponents.com / Home / IOSDataGrid < - $ 400

http://www.ioscomponents.com/Home/IOSDataGrid <-- $400

http://www.binpress.com/app/ios-data-grid-table-view/586 < - $ 130

http://www.binpress.com/app/ios-data-grid-table-view/586 <-- $130

有谁熟悉这些组件?

推荐答案

iOS表格视图始终是一列。在Mac OS上,您可以直接创建自己的内容。

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

也就是说,您可以创建显示所需内容的自定义表格视图单元格。事实上,这将非常容易。您要做的就是为UITableViewCell创建子类并为每个列定义视图(可能是UILabels),然后将它们作为单元格中的出口属性连接起来。然后装配表视图以为您使用的单元标识符注册该单元类。

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.

然后编写cellForRowAtIndexPath方法将数据安装到不同的插座属性中。

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

您也可以使用一个UICollectionView,但它看起来像一个带有自定义单元格的表视图更适合这个应用程序。

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.

这篇关于如何在Xcode中创建具有多个列的UI TableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆