【发布时间】:2019-07-24 17:21:12
【问题描述】:
我可以使用必要的数据从嵌入的UIKit tableview 转到SwiftUI 视图。我选择indexPath.row 和tableView(_didSelectRowAt)。
但是,@IBSegueAction 发生在 didSelectRowAt 之前。这使得 detailView 滞后一个选定的行:它显示先前选定的行。
我试图把 didSelectRowAt 首先,试图嵌入它们:没有机会 我在 WWDC 视频中看到应该可以选择正确的行,但无法从这个短片段中找出正确的语法(大约 6:00 分钟) https://developer.apple.com/videos/play/wwdc2019/231/
@IBSegueAction func MeasurementDetail(_ coder: NSCoder) -> UIViewController? {
return UIHostingController(coder: coder, rootView: PointDetailSwiftUIView(pointDetail: measurements[selectedMeasurementRow]))
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
selectedMeasurementRow = indexPath.row
}
我该如何解决这个问题?
【问题讨论】: