[英]How to use different table view cell class for different UITableView sections
[英]How to create Sections in Cell in Table View?
我正在创建收据视图,为此我正在使用 tableview。 我创建了多个单元来实现此功能。
这是我使用多个单元格的代码:
if indexPath.section == 4 {
let cell:ProductSummaryTitleCell = self.tblCategorySummary.dequeueReusableCellWithIdentifier("ProductSummaryTitleCell") as! ProductSummaryTitleCell
//set the data here
return cell
}
这是我的屏幕截图,我在我的 tableview 中到底想要什么。
[![收据查看][1]][1]
数据结构
(
{
Amount = "39.5";
Numbers = 5;
Productname = "BLACK PEPPER CHICKEN";
Upgrade = 0;
UpgradeCount = 0;
"product_id" = 53;
},
{
Amount = "10.9";
Numbers = 1;
Productname = "WHOLE SPRING CHICKEN";
Upgrade = 0;
UpgradeCount = 0;
"product_id" = 60;
})
这是我的类别回复
[
"category_type": mc,
"deleted_date": 0000-00-00 00:00:00,
"created_date": 2015-11-19 21:34:40,
"category_name": chicken,
"company_id": 1,
"category_invoice_name": Chicken,
"Ids": 358,
"updated_by": 2,
"category_icon_image": baa8ae5668029596f6efd9dc00d4c11f.png,
"created_by": 2,
"category_description": chicken,
"update_date": 2016-06-20 22:04:47,
"take_away_price": 0.5,
"branch_id": 1,
"parent_category": 0,
"set_menu": 1,
"pos_id": 6,
"category_status": 1,
"category_image": 6751d0f61304080148b79530d33c5735.png,
"is_deleted": 0,
"category_id": 11
]
我能够做类别总结。
但是在产品摘要中,您可以看到有部分。
我只使用一个 tableview。
我如何为特定单元格创建部分?
我取了产品摘要的一个单元格。
我只想要这个单元格中的部分。
我想根据屏幕截图创建产品摘要。
使用UITableViewHeader
作为类别摘要,使用Sections
作为产品摘要。 还要注意使用
tableView.dequeueReusableCellWithIdentifier("your_cell_identifier", forIndexPath: indexPath) as! YourTableViewCellClassName
而不是dequeueReusableCellWithIdentifier("your_cell_identifier")
。 发现后者有时容易出错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.