gpt4 book ai didi

ios - Xcode:将 TableView 添加到自定义单元格中

转载 作者:行者123 更新时间:2023-11-28 19:46:28 25 4
gpt4 key购买 nike

我正在尝试做某事,但既没有在网上找到一些示例,也不知道是否可行。

我需要以编程方式将表格添加到 tbaleview 的第一个单元格中。

当我尝试设置第二个表(第一个表中的那个)的委托(delegate)和数据源时,代码出现问题

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

[[NSBundle mainBundle] loadNibNamed:@"CellaMenu" owner:self options:NULL];
cell = cellaMenu;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.userInteractionEnabled = NO;
tabellaMenu = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
tabellaMenu.dataSource = self;
tabellaMenu.delegate = self;
[cell.contentView addSubview:tabellaMenu];
}

这样代码就循环了。如果我不设置委托(delegate)和数据源,表就会出现,但我需要它们来创建自定义处理程序。有什么提示吗?

最佳答案

最干净的方法是在 View Controller 中有另一个 UITableViewDataSource 和 UITableViewDelegate 兼容对象,然后将第二个 TableView 的委托(delegate)和数据源设置为该对象。

关于ios - Xcode:将 TableView 添加到自定义单元格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31875540/

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