XCode:设置多个 UITableView 列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3643093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:42:23  来源:igfitidea点击:

XCode: Setting up multiple UITableView columns

xcodeuitableview

提问by CrystalBlue

I haven't found a good answer to this, and I must be dense, but...

我还没有找到一个很好的答案,我一定很密集,但是......

I'm trying to get a table view set up with an image and a label in each row. The image would be an indicator image (New, In Progress, Stopped, Finished, ect.) and the label would be a particular issue name.

我试图在每行中设置一个图像和一个标签的表视图。该图像将是一个指示器图像(新的、进行中的、已停止的、已完成的等),标签将是一个特定的问题名称。

I can set up the table view normally with one column, but I can't find anything (in the code or in the Interface Builder) that sets the number of columns for a table. I assume I would have to set up two columns for the table.

我可以用一列正常设置表格视图,但我找不到任何设置表格列数的内容(在代码中或在界面生成器中)。我假设我必须为表格设置两列。

After that, I also need help on how I add the image to the first column and add the label to the second column. Basically, I want the same functionality and appearance you get from the iPhone's native Photo Album app, which shows a thumbnail on the left and a label in the center. And please treat me like I'm stupid, as I've searched all over, and everyone on the internet seems to have an option in the IB for table views that sets the number of columns...everyone but me. :P

之后,我还需要有关如何将图像添加到第一列并将标签添加到第二列的帮助。基本上,我想要与 iPhone 的原生相册应用程序相同的功能和外观,它在左侧显示一个缩略图,在中间显示一个标签。并且请像对待我一样愚蠢,因为我已经搜索了所有内容,并且互联网上的每个人似乎都可以在 IB 中选择用于设置列数的表视图......除了我之外的每个人。:P

回答by Marqueone

Your best course of action is to create your own custom UITableViewCell and specifically design it to include an image and a text label. Anything beyond that means you're going to have to start subclassing UITableView which isn't for the faint of heart. Another option is to look into a 3rd party library such as AQGridView.

您最好的做法是创建您自己的自定义 UITableViewCell 并专门设计它以包含图像和文本标签。除此之外的任何事情都意味着您将不得不开始继承 UITableView 这不适合胆小的人。另一种选择是查看 3rd 方库,例如 AQGridView。

回答by mj_

There's no such thing as a column in UITableViews. There's one of 2 routes that come to mind right off the bat.

UITableViews 中没有列这样的东西。马上就会想到两条路线之一。

1) Use 2 UITableViews that are side-by-side and sync'ed with one another whenever one moves (this may look a little weird)

1) 使用 2 个并排并在移动时彼此同步的 UITableViews(这可能看起来有点奇怪)

2) Stuff the label and the image into the same cell of the UITableView.

2) 将标签和图像填充到 UITableView 的同一个单元格中。

What's your choice?

你的选择是什么?

One more thing - are you programming for iPhone, iPad?

还有一件事 - 你在为 iPhone、iPad 编程吗?