0

I want to add a expandable tableview . After clicking the cell it should expand an other tableview inside it. I am sharing the screen shots.

enter image description here

Now i want after clicking the cell it should expand till the height of all data. and the view should be like this.

enter image description here

my code is

     func ParseJSON(){

    var MenuList = [Menu]()

    Alamofire.request(.GET, myUrl)
        .validate()
        .responseJSON { response in
            switch response.result
            {
            case .Success:
                if let value = response.result.value {
                    let json = JSON(value)
                    // print("JSON: \(json)")
                    for entity in json{
                        print(entity)

                    }

                }
            case .Failure(let error):
                print(error)
            }
    }

}

my modal class is

      import UIKit
        class Menu {
          var id: Int?
         var name: String?
         var image: UIImage?
         var coupon: Int?
         var icon: UIImage?
         var order: Int?
         var aname: Int?
         var options: Int?

init(id:Int,name:String,image:UIImage,coupon:Int,icon:UIImage,order:Int,aname:Int,options:Int){
        self.id = id
        self.name = name
        self.image = image
        self.coupon = coupon
        self.icon = icon
        self.order = order
        self.aname = aname
        self.options = options


    }
   }

how can i populate the menu names in tableview.after that when clicking in this tableview will expand till the size of whole data under which i am going to display the subcategory name.

see the json data:

     [
      {
         "id": "244",
          "name": "PIZZAS",
          "image": "",
          "coupon": "1",
          "icon": "",
          "order": "1",
          "aname": "",
          "options": "2",
          "subcategory": [
           {
            "id": "515",
            "name": "MARGARITA",
            "description": "Cheese and Tomato",
            "image": "",
            "icon": "",
            "coupon": "1",
            "order": "1",
            "aname": "",
            "options": "2",
            "item": [
                        {
                           "id": "1749",
                           "name": "9 Inch Thin & Crispy Margarita",
                           "description": "",
                           "price": "3.40",
                           "coupon": "1",
                           "image": "",
                           "options": "2",
                           "order": "1",
                           "addon": "495",
                           "aname": "",
                           "icon": ""
                    }]
              }]
      }]
PRADIP KUMAR
  • 489
  • 1
  • 9
  • 31
  • go through this link... https://www.cocoacontrols.com/controls/jkexpandtableview – Priyanka Kanse Jun 21 '16 at 09:14
  • @PriyankaKanse Thus link uses the third party "JKExpandTableView" from github. i don't want to include a github package. please refer other in which i can create all things by myself ,not any helper predefined class – PRADIP KUMAR Jun 21 '16 at 09:32
  • @PriyankaKanse and also this one is not in swift. only in objective C – PRADIP KUMAR Jun 21 '16 at 09:33
  • you can use objc bridging in your swift project & u can use this code. If you dont wanna use third party framework kindly go through this stack overflow question http://stackoverflow.com/questions/5050534/how-to-make-an-expandable-table-view-cell – Priyanka Kanse Jun 21 '16 at 10:45
  • @Priyanka Now i am able to use the expanded tableview cell. But Now how to add datasource and delegate methods inside custom tableview cell when i add nested tableview – PRADIP KUMAR Jun 21 '16 at 13:12
  • I am not getting your exact question... please elaborate your question... – Priyanka Kanse Jun 22 '16 at 11:41
  • Ok i am going to edit the question than can able to understand – PRADIP KUMAR Jun 28 '16 at 09:06
  • Pradip, please don't post duplicate questions. I've closed this one as a duplicate of your other one. Edit the other one if needed. Or better: if you have a new, different question, make it so the questions don't look the same (decoding JSON vs populating the table view is two different questions). Thank you. :) – Eric Aya Jun 28 '16 at 09:33

0 Answers0