我正在创建收据视图,为此我正在使用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")。发现后者有时容易出错。

关于ios - 如何在表格 View 的单元格中创建节?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40020007/

10-11 00:40
查看更多