2

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.

[![Receipt View][1]][1]

Data Structure

(
    {
    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;
})

this is my category response

[
"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.

Krutarth Patel
  • 3,407
  • 6
  • 27
  • 54
  • 2
    You might find it useful to look at this recent discussion, which explains how to nest a table view inside a table view cell: http://stackoverflow.com/questions/17398058/is-it-possible-to-add-uitableview-within-a-uitableviewcell – Marcus Oct 13 '16 at 11:50
  • Can you show how your data array looks like? – Bista Oct 13 '16 at 11:57
  • @Mr.Bista i updated question with array structure of products which i want to display.each category contains this data – Krutarth Patel Oct 13 '16 at 11:59
  • 1
    Are your sure that its the full data information? Because I do not see anything, that separates _Category Summary_, _Product summary(Sub Category: Chicken, Fish etc.)_ – Bista Oct 13 '16 at 12:04
  • @Mr.Bista done.plz check is this sufficient ? – Krutarth Patel Oct 13 '16 at 12:09

2 Answers2

1

In a single tableview show the "Category Summary" as tableview header and "Product Summary" you can use the section and cells.

Please below image you will get an idea.

enter image description here

Also you can try by considering the following options (If Category Summary is dynamic):

enter image description here

Suhas Arvind Patil
  • 1,732
  • 1
  • 19
  • 31
1

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

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

Mathews
  • 733
  • 5
  • 11