【发布时间】:2020-09-01 10:25:07
【问题描述】:
我刚刚使用UIViewRepresentable 创建了一个 UIKit tableView。
如果选择了 tableCell,现在我需要呈现一个新的 SwiftUI 视图。
这是我到目前为止所做的:
struct UIKitTableView: UIViewRepresentable {
@Binding var showDetail: Bool
func makeCoordinator() -> Coordinator {
Coordinator(showDetail: self.$showDetail)
}
class Coordinator: NSObject, UITableViewDataSource, UITableViewDelegate {
@Binding var showDetail: Bool
/// Did select row at
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
self.showDetail = true
}
现在在我的 SwiftUI 视图中,我可以显示视图:
NavigationLink(destination: CellDetail(), isActive: self.$showDetail) {
但我还需要传递相关单元格的数据,我想知道哪种方法最好。
我的另一个问题是:@Binding showDetail 方法是否正确?如何改进我的解决方案?
【问题讨论】:
-
您找到解决方案了吗?
标签: ios uitableview swiftui uikit segue