gpt4 book ai didi

ios - 是否可以在 Swift 的 UITableViewCell 中添加 UITableView

转载 作者:行者123 更新时间:2023-11-29 02:00:17 27 4
gpt4 key购买 nike

如何在UITableViewCell中添加UITableView,每个UITableViewCell中的UITableView是不同的数据?

如何在 UITableView 中显示这个 json:

"DiviDeta": [
{
"Id": 12453,
"Nombre": "BATIDO",
"Precio": 1800,
"Sabores": [
{
"Id": 564,
"Nombre": "FEIJOA"
},
{
"Id": 565,
"Nombre": "GUANABANA"
},
{
"Id": 562,
"Nombre": "LULO"
},
{
"Id": 561,
"Nombre": "MANGO"
},
{
"Id": 566,
"Nombre": "MARACUYA"
},
{
"Id": 563,
"Nombre": "MORA"
}
]
}

最佳答案

我以前在 Objective C 中做过,但不是很快。

以下是在 TableviewCell 上添加 TableView 的步骤:

  1. 使用 xib 制作 TableView Cell 类。

@interface CollapsableCell_iPhone : UITableViewCell <UITableViewDelegate,UITableViewDataSource>

  1. 在内容 View 上添加 View 。在该 View 上添加 TableView 并将委托(delegate)设置为 TableView 单元格类。

enter image description here

  1. 在 tableview 单元格类中实现委托(delegate)方法。

  2. 根据需要多次在您的 Tableview 中使用此单元格。

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CollapsableCell_iPhone" owner:self options:nil];

    CollapsableCell_iPhone *cell = (CollapsableCell_iPhone *)[nib lastObject];

关于ios - 是否可以在 Swift 的 UITableViewCell 中添加 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30461315/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com