[英]Custom prototype cells for Table View
I've been trying to figure out lately how to display data from a database in a particular way, as described on the picture below: 我最近一直在尝试找出如何以特定方式显示数据库中的数据,如下图所示:
Basically, as seen on many brand websites, I'd like to display each item from the database as rectangular cells, with a large image describing the item and 1 to 3 labels to put a title/subtitle/price tag. 基本上,就像在许多品牌网站上看到的那样,我想将数据库中的每个项目显示为矩形单元格,并用大图像描述该项目以及1到3个标签来放置标题/字幕/价格标签。
I had no idea how to deal with it, to me it looked like creating some kind of table view with custom prototype cells, but I did not find any answers on the internet. 我不知道如何处理它,对我来说,这就像用自定义的原型单元创建某种表格视图一样,但是我在互联网上找不到任何答案。
I'm sure the answer is quite simple but I can't figure it out unless doing entirely programmatically? 我敢肯定答案很简单,但除非完全以编程方式完成,否则我无法弄清楚。
Yes, as jkaufman said: UICollectionView
is made for this purpose. 是的,正如jkaufman所说:
UICollectionView
是为此目的而制作的。 You may create a custom UICollectionViewCell
in Interface Builder with a UIImageView
and a UILabel
as you illustrated. 如图所示,您可以在Interface Builder中使用
UIImageView
和UILabel
创建自定义UICollectionViewCell
。 Be sure to give your custom IUCollectionViewCell
a Reuse Identifier so you UICollectionViewDataSource
can specify it. 确保为自定义
IUCollectionViewCell
一个重用标识符,以便UICollectionViewDataSource
可以指定它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.