swift - 如何在现有 Storyboard Tab Bar Controller 中使用 Hosting Controller for SwiftUI?
问题描述
我正在尝试使用托管控制器将 SwiftUI 视图包含在现有的故事板标签栏控制器中。我已经使用Relationship Segue 将Hosting View Controller 连接到Storyboard 上的Tab Bar Controller。以下是我从阅读其他帖子中尝试过的,但我得到的只是黑屏。任何帮助,将不胜感激。谢谢你。
import UIKit
import SwiftUI
class SingleSearchHost: UIHostingController<SingleSearch>{
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder, rootView: SingleSearch())
}
}
解决方案
我的问题的答案是将类分配给 Storyboard 身份检查器中的主机控制器。感谢@Adam 回答这个问题!
推荐阅读
- r - 按组划分的两个日期之间的平均值
- reactjs - 如何在 React 测试库/Jest 中测试按钮是否有条件启用
- javascript - API请求后如何正确发送电子邮件?
- selenium-webdriver - 即使任何一个子节点失败,测试也通过(在扩展报告中)
- r - 如何在 geom_text 粘贴命令中使用 `parse = T` 和类似 round 的函数?
- android - 您如何在您的 Android 应用程序中捆绑一组特定的表情符号?(如 Discord 或 Facebook)
- sql-server - 如何在 Angular 模板中显示 SQL Server 图像(blob 图像)?
- android - android.icu.text.DecimalFormat 重置货币分隔符
- typescript - 如何在我的 nx 工作区中覆盖 eslint 规则?
- visual-studio-2019 - 如何强制 Visual Studio 2019 生成 .csproj.user 文件?