我想添加一个可扩展的tableview。单击单元格后,它应该展开其中的另一个tableview。 我正在分享屏幕截图。
现在我想点击单元格之后它应该扩展到所有数据的高度。并且视图应该是这样的。
我的代码是
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)
}
}
}
我的模态类是
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
}
}
如何在tableview中填充菜单名称。之后单击此表视图将扩展到我要显示子类别名称的整个数据的大小。
查看json数据:
[
{
"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": ""
}]
}]
}]