【发布时间】:2019-12-27 05:29:21
【问题描述】:
在我的场景中,我有一个静态的tableview。现在我需要在静态tableview 的底部添加动态tableview。根据我的情况,我无法将两者混合在一个 tableview 中。所以,我必须添加静态tableview 页脚或任何其他底部附件视图的动态表格视图底部。 我尝试了以下方法
- 在静态
celltableview 中添加了footer视图,并且在该页脚中我添加了动态 tableview,但动态 tableview 也不会根据其单元格计数扩展页脚高度,它不允许动态单元格选择。 - 添加了
accessory视图但不知道怎么添加到tableview的底部
我的 StaticTableview 单元格代码
override func numberOfSections(in tableView: UITableView) -> Int {
return 4
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return " "
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 2
} else if(section == 1) {
return 1
} else if(section == 2) {
return 3
} else {
return 1
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath) as UITableViewCell
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
if indexPath.section == 0 && indexPath.row == 0 { }
else if indexPath.section == 0 && indexPath.row == 1 {
} else if indexPath.section == 1 && indexPath.row == 0 {
} else if indexPath.section == 2 && indexPath.row == 0 {
} else if indexPath.section == 2 && indexPath.row == 1 {
} else if indexPath.section == 2 && indexPath.row == 2 {
} else if indexPath.section == 2 && indexPath.row == 3 {
} else {
}
}
【问题讨论】:
-
是什么阻止您拥有两个表格视图控件?
-
@ElTomato 仅在我维护两个 tableview 时滚动问题。现在我将另一个静态单元格添加到该单元格中的静态表格视图中,我正在尝试添加动态表格视图。
-
创建 2 个 UITableView 以便您实现目标。没有这个你做不到。
-
@AyazAkbar 静态表格视图单元格中的表格视图怎么样? stackoverflow.com/questions/17398058/…
-
@iosdev 所以你需要在 UITableViewCell 中创建 UItableView。这是正确的方法。
标签: ios swift uitableview