ios - 使用 SwiftUI 按钮导航到 Storyboard
问题描述
这是我的 SwiftUI 代码:
//
.navigationBarItems(trailing:
HStack {
Button(action: {
AddView() // NOT WORKING
}) {
Image(systemName: "plus.square.fill")
.font(.largeTitle)
}.foregroundColor(.blue)
})
如您所见,我想调用 AddView(),以使用导航栏中的按钮导航到添加视图。这是我的 AddView() 函数:
struct AddView: UIViewControllerRepresentable {
typealias UIViewControllerType = SwipeViewController
func makeUIViewController(context: Context) -> SwipeViewController {
let sb = UIStoryboard(name: "Storyboard", bundle: nil)
let viewController = sb.instantiateViewController(identifier: "add") as! SwipeViewController
return viewController
}
func updateUIViewController(_ uiViewController: SwipeViewController, context: Context) {
}
}
它确实导航到我称为“添加”的 Storyboard VC...
怎么了?谢谢你!
解决方案
推荐阅读
- clean-architecture - 清洁架构:用例混合
- spring - 尝试进行聚合过滤器将子字段与可能值数组进行比较
- python - Python 程序结束时会发生什么?
- sql - 如何正确地为单个历史表编写触发器,其中的数据来自两个单独的表
- python - 按选择结果过滤
- visual-studio-code - 2021 年 7 月更新 - 旋转的执行单元符号去哪里了?
- sql - 删除除两个尾随零和千位分隔符之外的所有内容
- matrix - 删除/隐藏在 SSRS 的矩阵报告中具有零值的行
- social-networking - 未来的社交网络网站和应用程序
- javascript - 将值推入数组