【发布时间】:2017-12-18 06:16:17
【问题描述】:
以上是我的内心细胞。我想在下面的单元格中加载这个单元格。内部细胞的数量是动态的。
以上是我的主要单元格。红色部分是 UIView。我想将innerCell 的数量动态添加到UIView 中。我试过下面的代码
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let mainCell = tableView.dequeueReusableCell(withIdentifier: "FlightCellMain", for: indexPath) as? FlightCellMain
let innerCell = tableView.dequeueReusableCell(withIdentifier: "FlightCell", for: indexPath) as? FlightCell
mainCell?.flightCellView.addSubview(innerCell!)
mainCell?.backgroundColor = .clear
innerCell?.backgroundColor = .clear
// innerCell?.innerCellWidthConst.constant = (mainCell?.mainView.frame.width)!
self.showStopsView(2, self.airportlist, (innerCell?.leftRound)!, (innerCell?.rightRound)!, (innerCell?.centerLine)!, (innerCell?.routeView)!)
mainCell?.flightCellViewHieghtConst.constant = (mainCell?.flightCellViewHieghtConst.constant)! + 125
innerCell?.layoutIfNeeded()
mainCell?.layoutIfNeeded()
return mainCell!
}
但是结果是这样的。我提供了自动布局。当我单独运行这两个单元格时,它适合它的内容。我在做什么错?
上图是我想要实现的模型。航班数量的详细信息是动态的。
【问题讨论】:
-
对于内部表格视图单元格,您需要在单元格视图中添加 tableView 并将 tableView 单元格加载到其中。并且内部 tableView 视图必须具有固定高度。
-
@Aman19ish 请查看已编辑的问题。我添加了我期待的结果屏幕。
-
好的。但是对于这个 UI 为什么你使用内部单元格。如果您需要 tableVIew 内部单元格的代码,请将您的邮件 ID 发送给我。
-
它没有得到这样的结果..
-
我想,我没有得到你的问题。但据我说,对于 Inner tableView 单元格不使用自动尺寸。(它不工作)
标签: ios swift uitableview uiview