【发布时间】:2021-05-04 02:01:51
【问题描述】:
嗨 :) 我有一个 tableView,我想在我的 UITableViewCell 中有一个 tableView,现在我想在 UIView 类中创建一个自定义 tableView,然后使用 UIView 在 UITableViewCell 中呈现它,我想知道是有可能,或者我正在处理错误的问题:)
这是我想要实现的图片:Link
【问题讨论】:
标签: ios swift uitableview uiview
嗨 :) 我有一个 tableView,我想在我的 UITableViewCell 中有一个 tableView,现在我想在 UIView 类中创建一个自定义 tableView,然后使用 UIView 在 UITableViewCell 中呈现它,我想知道是有可能,或者我正在处理错误的问题:)
这是我想要实现的图片:Link
【问题讨论】:
标签: ios swift uitableview uiview
虽然您可以将UITableView 添加到任何UIView,这也意味着添加到UITableViewCell,但您尝试实现的目标看起来像UITableView 和UITableView.Style.insetGrouped。
这种新的表格视图样式在 iOS13 中可用。
只需使用这种样式初始化您的表格视图,例如:
let tableView = UITableView(frame: .zero, style: .insetGrouped)
您可以在此处查看文档:(https://developer.apple.com/documentation/uikit/uitableview/style/insetgrouped)
在这个帖子里,有这个UITableView.Style的截图:
TableView with inset grouped style: Have rounded corners even with hidden cells
【讨论】:
UITableView 并将其外观修改为类似于.insetGrouped,而不是将UITableView 添加到UIView。
您可以使用inset grouped style 实现这种外观 在 UITableView 上并将sections 添加到 UITableView
【讨论】: