如何在表格视图的单元格中创建节? [英] How to create Sections in Cell in Table View?

查看:62
本文介绍了如何在表格视图的单元格中创建节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建收据视图,为此我正在使用tableview.我创建了多个单元来实现此功能.

I am creating Receipt view, for this i am using tableview. I have created multiple cell to achieve this functionality.

这是我使用多个单元格的代码:

Here is my code to use multiple cell:

if indexPath.section == 4    {
    let cell:ProductSummaryTitleCell = self.tblCategorySummary.dequeueReusableCellWithIdentifier("ProductSummaryTitleCell") as! ProductSummaryTitleCell
    //set the data here
    return cell
}

这是我的萤幕撷取画面,是我在资料检视中真正想要的.

and here is my screenshot what i exactly want in my tableview.

[![收据视图] [1]] [1]

[![Receipt View][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
]

我可以进行类别摘要.
但是在产品摘要中,您可以看到其中的部分.

I am able to do Category summary.
But in product summary you can see there are sections.

我仅使用一个表格视图.
如何为特定的单元格创建部分?
我用一个单元格的产品摘要".
我只想要该单元格中的部分.
我想根据屏幕快照创建产品摘要.

I am using only one tableview.
How i can create section for particular cell?
I take one cell of Product Summary.
I want only sections in this cell.
I want to create product summary according to screenshot.

推荐答案

UITableViewHeader 用于类别摘要,将 Sections 用于产品摘要.还要小心使用

Use UITableViewHeader for the category summary and Sections for the product summary. Also take care to use

tableView.dequeueReusableCellWithIdentifier("your_cell_identifier", forIndexPath: indexPath) as! YourTableViewCellClassName

而不是 dequeueReusableCellWithIdentifier("your_cell_identifier").发现后者有时容易出错.

rather than dequeueReusableCellWithIdentifier("your_cell_identifier"). The latter is found to be error prone at times.

这篇关于如何在表格视图的单元格中创建节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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