问题描述
我刚刚使用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方法正确吗?如何改善我的解决方案?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)